Set-ExecutionPolicy-ExecutionPolicyRemoteSigned-ScopeCurrentUser 将执行策略设置为RemoteSigned后,Get-TimeService.ps1脚本将成功运行。 PowerShell .\Get-TimeService.ps1 Output Status Name DisplayName --- --- --- Running W32Time Windows Time 总结 在本章中,你...
如果您想要變更登錄機碼中的特定專案,您可以使用數種可能的方法之一。 此範例會修改 底下的HKEY_CURRENT_USER\EnvironmentPath專案。Path專案會指定要尋找可執行檔的位置。 使用Get-ItemProperty擷取Path專案的目前值。 加入新的值,並將它與 區隔開;。 搭配Set-ItemProperty指定的機碼、專案名稱和值來修改登錄專案。
Get-Date [[-Date] <DateTime>] [-Year <Int32>] [-Month <Int32>] [-Day <Int32>] [-Hour <Int32>] [-Minute <Int32>] [-Second <Int32>] [-Millisecond <Int32>] [-DisplayHint <DisplayHintType>] [-Format <String>] [-AsUTC] [<CommonParameters>]Power...
Get-PSDrive Output 複製 Name Used (GB) Free (GB) Provider Root --- --- --- --- --- Alias Alias C 18.56 107.62 FileSystem C:\ Cert Certificate \ D FileSystem D:\ Env Environment Function Function HKCU Registry HKEY_CURRENT_USER HKLM Registry HKEY_LOCAL_MACHINE Variable Variabl...
次の例では、パラメーター セットで Computer ComputerName パラメーター、パラメーター セットの User UserName パラメーター、および両方のパラメーター セットの Summary パラメーターを宣言します。PowerShell コピー param( [Parameter(Mandatory, ParameterSetNa...
Get-ChildItem-Path Cert:\CurrentUser\My\|Where-Object{$_.Subject-match"mylab.wang.io"}|Export-Certificate-FilePathC:\Users\Administrator\Desktop\cert\mylab.wang.io.cer 总结 证书是保护网络通信和数据的重要工具。在 Windows 中,我们可以使用 PowerShell 来创建和导出自签名证书。虽然自签名证书在公共互...
指定容器的 ID。 类型:String Position:0 默认值:None 必需:True 接受管道输入:True 接受通配符:False -Credential 指定有权执行此作的用户帐户。 默认值为当前用户。 键入用户名(如User01或Domain01\User01),或输入由cmdlet 生成的Get-Credential对象。 如果键入用户名,系统会提示输入密码。
Get-ExecutionPolicy-ScopeCurrentUser 更改执行策略 若要更改 Windows 计算机上的 PowerShell 执行策略,请使用Set-ExecutionPolicycmdlet。 更改立即生效。 无需重启 PowerShell。 如果为 ScopesLocalMachine或CurrentUser设置执行策略,更改将保存在配置文件中,并在再次更改之前保持有效。
Get-WinEvent -FilterHashtable @{LogName='Security';Id=4634} //已注销账户 Get-EventLog -LogName System -EntryType Error //检测到系统错误 【获取登录信息】 gwmi Win32_LoggedOnUser //成功登录的记录 gwmi Win32_LoggedOnUser | ft Antecedent //成功登录的用户 ...
示例:Get-WmiObject -Class Win32_Process | Select-Object ProcessId, Name, CommandLine,选择显示进程的 ID、名称和命令行。 3.3 远程操作 可以使用-ComputerName参数在远程计算机上执行命令。 示例:Get-WmiObject -Class Win32_BIOS -ComputerName Server01,在名为 "Server01" 的远程计算机上检索 BIOS 信息。