如何解决无法在 powershell 中运行 powershell 脚本
如果我运行此代码,它将运行文件
{Write-host "Please Enter the email address of the user you want to check the permissions"
$user = Read-Host
Powershell.exe C:\Temp\Report\Reports.ps1}
但是如果我像这样运行它,这就是我需要做的
{ Write-host "Please Enter the email address of the user you want to check the permissions"
$user = Read-Host
Powershell.exe C:\Temp\Report\Reports.ps1 -processOneDrive $true -OneDriveEmail $user}
我收到此错误
Powershell.exe : C:\Temp\ReportSharedFiles\ReportSharedFiles.ps1 : Missing an argument for parameter 'OneDriveEmail'. Specify a
At C:\Temp\ReportSharedFiles\Full Exchange Script Menu.ps1:88 char:2
+ Powershell.exe "c:\Temp\ReportSharedFiles\ReportSharedFiles.ps1" -pr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (C:\Temp\ReportS...il'. Specify a :String) [],RemoteException
+ FullyQualifiedErrorId : NativeCommandError
parameter of type 'System.String' and try again.
At line:1 char:71
+ ... haredFiles\ReportSharedFiles.ps1 -processOneDrive True -OneDriveEmail
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [ReportSharedFiles.ps1],ParameterBindingException
+ FullyQualifiedErrorId : MissingArgument,ReportSharedFiles.ps1
我做错了什么,我怎样才能让它工作?任何帮助将不胜感激
解决方法
我相信它要求您在错误中输入一个 sting 参数
'System.String' 类型的参数,然后重试。
希望能成功>
{ [string]$user = Read-Host "Please Enter the email address of the user you want to check the permissions"
Powershell.exe C:\Temp\Report\Reports.ps1 -processOneDrive $true -OneDriveEmail $user}
,
我已经想通了。似乎在另一个脚本中运行 powershell 脚本并输入参数时。当涉及到 -processOneDrive $true 时,它试图将其转换为导致错误的 boolem。我将其更改为 1,这肯定意味着正确,因此代码看起来像这样
Powershell.exe "c:\Temp\Report\Reports.ps1" -processOneDrive 1 -OneDriveEmail $user
现在运行顺利。感谢所有试图帮助我解决这个问题的人:)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。