Long, long ago when I was using my first Microsoft product, I knew one way to get input from the user. The product was Commodore BASIC (in those days we wrote it in uppercase and knew it stood for Beginners All-
此方法介绍了在 Windows PowerShell 脚本中接受用户输入的多种方法。学习目标 完成本模块后,学习者将能够: 确定脚本中可能更改的值。 说明如何使用 Read-Host 接受用户输入。 说明如何使用 Get-Credential 接受用户凭据。 说明如何使用 Out-GridView 获取用户输入。 使用Read-Host、Get-Credential 和 Out-Grid...
在PowerShellGet 1.x 版本中,默认值为AllUsers,这需要提升安装。 Type:String Accepted values:CurrentUser, AllUsers Position:Named Default value:CurrentUser Required:False Accept pipeline input:False Accept wildcard characters:False -WhatIf 显示运行后Update-Module会发生什么情况。 cmdlet 未运行。
确定Get-Service命令生成的输出类型。 PowerShell Get-Service-Namew32time |Get-Member Get-Service生成ServiceController对象类型。 Output TypeName: System.ServiceProcess.ServiceController 如Stop-Servicecmdlet 的帮助所示,InputObject参数可以通过管道按值接收ServiceController对象。 这意味着,当你通过管道将Get-Servicecmdl...
Get-WinEvent 参考 模块: Microsoft.PowerShell.Diagnostics 获取本地和远程计算机上的事件日志和事件跟踪日志文件中的事件。 语法 PowerShell复制 Get-WinEvent[[-LogName] <String[]>] [-MaxEvents <Int64>] [-ComputerName <String>] [-Credential <PSCredential>] [-FilterXPath <String>] [-Force] [-Oldes...
The OrganizationalUnit parameter filters the results based on the object's location in Active Directory. Only objects that exist in the specified location are returned. Valid input for this parameter is an organizational unit (OU) or domain that's returned by the Get-OrganizationalUnit cmdlet. You...
Get-EventLog -LogName System -EntryType Error //检测到系统错误 【获取登录信息】 gwmi Win32_LoggedOnUser //成功登录的记录 gwmi Win32_LoggedOnUser | ft Antecedent //成功登录的用户 【开关机相关】 Stop-Computer //关机 Restart-Computer //重启 ...
[environment]::setenvironmentvariable("PATH","D:","User") PowerShell脚本执行策略 get-executionpolicy # 查看当前运行策略 代码语言:javascript 代码运行次数:0 运行 AI代码解释 策略分类 > get-help set-executionpolicy 语法 Set-ExecutionPolicy [-ExecutionPolicy] {Unrestricted | RemoteSigned | AllSigned | Res...
<input> -replace <regular-expression>, <substitute> 运算符使用正则表达式将值的所有或部分替换为指定的值。 可以将运算符用于许多管理任务,例如重命名文件。 例如,以下命令将所有 .txt 文件的文件扩展名更改为 .log: PowerShell 复制 Get-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace '...
键入用户名(如 User01 或Domain01\User01),或输入 PSCredential 对象,例如由 Get-Credential cmdlet 生成的用户名。 仅当命令中还使用了 Proxy 参数时,此参数才有效。 不能在同一命令中使用 ProxyCredential 参数和 ProxyUseDefaultCredentials 参数。 展开表 类型: PSCredential Position: Named 默认值: Current u...