使用Get-ItemProperty 命令可以获取指定注册表路径下的键值信息。 powershellCopy Code # 获取注册表项的值 Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name "ShellState" 2. 设置注册表项的值 使用Set-ItemProperty
可以将函数添加到脚本模块中,将该模块放在$env:PSModulePath中定义的位置,然后调用这些函数,而无需查找保存函数的位置。 使用PowerShellGet模块,可以轻松地在 NuGet 存储库中共享 PowerShell 模块。PowerShellGet随 PowerShell 5.0 及更高版本一起提供。 也可为 PowerShell 3.0 及更高版本单独下载。
列出磁盘驱动器的详细信息 detail disk `Get-PhysicalDisk 挂载ISO 镜像 无直接命令 Mount-DiskImage -ImagePath <路径> 卸载ISO 镜像 无直接命令 Dismount-DiskImage -ImagePath <路径> 设置磁盘为脱机 offline disk Set-Disk -IsOffline $true 设置磁盘为联机 online disk Set-Disk -IsOffline $false 磁盘初始...
-Path:设置获取文件的路径,可以使用通配符,因此Get-Content 可以一次性读取多个文件或者多个目录的内容。 -Filter:用来设置限定 Path 参数的筛选条件。 -Include:包含一个或多个项作为字符串数组,同样是作为Path筛选条件使用 -Exclude:排除一个或多个项作为字符串数组,同样是作为Path筛选条件使用 -Force:可以替代只读属...
如果已安装的模块已是最新版本,则不会更新该模块。 如果在 中$env:PSModulePath找不到模块,则会显示错误。 若要显示已安装的模块,请使用Get-InstalledModule。 示例 示例1:更新所有模块 此示例将所有已安装的模块更新到联机库中的最新版本。 PowerShell ...
$users=import-csv-Path$inputpathforeach($userrecordin$users) {$upn=$userrecord.UserPrincipalNameif($null-eq$upn) {throw"no UserPrincipalName"}$u=$nulltry{$u=Get-MgUser-UserId$upn} catch {write-error"no user$upn"}if($u-eq$null) {continue}if($existingusers2.contains($u.Id)) {con...
'Background Intelligent Transfer Service','Windows Time'|Out-File-FilePath$env:TEMP\services.txt 可以使用括号将一个命令的输出作为参数的输入传递给另一个命令。 PowerShell Stop-Service-DisplayName(Get-Content-Path$env:TEMP\services.txt) 此概念类似于代数中的运算顺序。 就像先计算括号中的数学运算一样...
Get-WmiObject Win32_VideoController //获取显卡信息 【获取Windows产品ID】 2种方式 第一种:CMD命令行运行control system查看产品ID 第二种:CMD命令行运行powershell,输入命令查看 (Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -ErrorAction Stop).ProductId...
{$_.PSIsContainer } |foreach{ gci-Path$_.FullName-Recurse-includeAssemblyInfo.* }if($files) {Write-Verbose"Applying$NewVersionto $($files.count) files."foreach($filein$files) {$filecontent=Get-Content($file) attrib$fi 用于访问 REST API 的示例脚本...
Get-WinEvent[-Path] <String[]> [-MaxEvents <Int64>] [-Credential <PSCredential>] [-FilterXPath <String>] [-Oldest] [<CommonParameters>] PowerShell复制 Get-WinEvent[-MaxEvents <Int64>] [-ComputerName <String>] [-Credential <PSCredential>] [-FilterHashtable] <Hashtable[]> [-Force] [...