我正在使用 powershell 与文件夹及其所有子文件夹进行比较,并且它在我的本地计算机上工作正常。但是当我在服务器上尝试它时,它给了我错误并附加
Microsoft.PowerShell.Core\FileSystem::\\
到所有文件
如果有人之前做过这样的工作请帮忙
我的脚本是
$Path = '\\Server1\Folder1'
Get-ChildItem $Path -Recurse | ? { !$_.PSIsContainer } | % {
Add-Member -InputObject $_ -MemberType NoteProperty -Name RelativePath -Value $_.FullName.Substring($Path)
$_
}
它给了我错误
Cannot convert argument "0", with value: "Microsoft.PowerShell.Core\FileSystem::\\Server1\Folder1\ServerListPowershell", for "Substring" to type "System.Int32": "Cannot convert value "M
icrosoft.PowerShell.Core\FileSystem::\\Server1\Folder1\ServerListPowershell" to type "System.Int32". Error: "Input string was not in a correct format.""
At C:\Users\cwr.satish.kumar\AppData\Local\Temp\898f72f1-a0d3-4003-b268-128c5efc9f2b.ps1:14 char:108
+ Add-Member -InputObject $_ -MemberType NoteProperty -Name RelativePath -Value $_.FullName.Substring <<<< ($Path)
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
请帮忙
Try the Convert-Path
cmdlet:
PS> Convert-Path Microsoft.PowerShell.Core\FileSystem::C:\windows\system32
C:\windows\system32
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)