0
我想導入PowerShell腳本來使用它的功能使用Python,但我使用的語法似乎是關閉的。從Python運行PowerShell功能不工作
p = subprocess.call(["C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe", '-Command', '&{". .\powerview.ps1"; & Invoke-CustomShareFinder}'])
繼thses說明:How to run a Powershell function through a Python script
錯誤:
. .\powerview.ps1
& : The term 'Invoke-CustomShareFinder' 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:32
+ &{". .\powerview.ps1"; & Invoke-CustomShareFinder}
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-CustomShareFinder:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
基本上它的這個劇本,但我改名爲它的功能: https://github.com/PowerShellEmpire/PowerTools/blob/master/PowerView/powerview.ps1
任何想法?
編輯:
手動導入和PowerShell的推出時,此功能工作:
PS C:\Users\gcaille\Documents\my_program> . .\powerview.ps1
PS C:\Users\gcaille\Documents\my_program> Invoke-CustomShareFinder
\\server\ADMIN$ - Remote Admin
\\server\C$ - Default share
\\server\IPC$ - Remote IPC
代碼是否(命令內容)在PowerShell終端/ ISE中運行? – wOxxOm
是的,編輯問題與證明 –