我试图使用PowerShell中的以下代码获取短路径.对于某些文件夹,它可以工 对某些人来说,它不起作用.
$a = New-Object -ComObject Scripting.FileSystemObject
$f = $a.GetFile("C:\Program Files\Internet Explorer")
$f.ShortPath
Run Code Online (Sandbox Code Playgroud)
虽然文件夹可用,但我收到以下错误:
Exception calling "GetFile" with "1" argument(s): "Exception from HRESULT: 0x800A0035 (CTL_E_FILENOTFOUND)"
At C:\Misc\GetShortPath.ps1:4 char:1
+ $f = $a.GetFile("C:\Program Files\Internet Explorer")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
Run Code Online (Sandbox Code Playgroud)
有人可以请帮助
我试图将2个参数传递给PS脚本,该脚本将修补远程计算机上的SQL Server。这是我使用的代码:
$Patcher = "\\remoteShareLocation\SQLpatcher.ps1"
$ver = "SQL2012"
$inst = "NEWINST"
Invoke-Command -ComputerName RMTMACHINE -credential dmn\usrname -ScriptBlock {$Patcher $ver $inst}
Run Code Online (Sandbox Code Playgroud)
这会要求提供凭据,但不会运行,也不会显示任何输出。语法有什么问题吗?还有其他替代cmdlet吗?