I have a Windows 2016 Server with Powershell 5.0 installed on it. I'm trying to create a folder on a network file share (which is also on the same server, but I access the file share with \server\backup instead of D:\backup) with Powershell command below.
However the code below occasionally throw errors.
System.ArgumentException: Invalid Path: '\\server\backup\PSBackup\newFolder'.
at Microsoft.SqlServer.Management.PowerShell.SqlPath..ctor(String path)
at Microsoft.SqlServer.Management.PowerShell.SqlServerProvider.NewItem(String path, String type, Object newItem)
at System.Management.Automation.SessionStateInternal.NewItemPrivate(CmdletProvider providerInstance, String path, String type, Object content, CmdletProviderContext context)
I have a powershell script which creates folders in an order, the same code creates the first folder, but throws error for the second folder creation.
Did you ever face such a problem when creating folder on a network share? By the way the same powershell script works without any problem on my dev machine (Windows 2012 R2) and Windows 2008 R2 servers.
$rootFolder = "\\server\backup\PSBackup"
$folderName = "newFolder"
$createdDirectory = New-Item -Path $rootFolder -ItemType "directory" -Name $folderName
$createdDirectory = New-Item -LiteralPath (Join-Path -Path $rootFolder -ChildPath $folderName) -ItemType Directory? - Theo[ ]- js2010