Я хотел бы запустить блок скриптов, чтобы найти программное обеспечение, доступное в системе.Ниже приведен мой фрагмент кода.
$scriptBlock = {
$key = Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' |
Where-Object { $_.DisplayName -match 'Skype' };
return $key
}
$installed64 = @(& "$env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NoProfile -NonInteractive -Command $scriptBlock)
Когда я выполнил вышеупомянутую команду на 64-битной машине, я получаю сообщение об ошибке:
& : The term 'C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\powershell.exe' is
not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:20
+ ... led64 = @(& "$env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powersh ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\WINDOWS\sysn...\powershell.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Я хочу запустить команду в "NT AUTHORITY \ SYSTEM "PowerShell.
Как запустить скрипт-блок?