# 获取当前登录的用户 $env:USERNAME # 获取计算机名称 $env:COMPUTERNAME # 检查当前用户是否为管理员 ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) # 获取当前用户所属的组列表 $groups = [System...
5、set-location,简称sl,相当于linux里的cd命令,这里cd也可以用,但是powershell跟cmd下不一样,powershell里的cd命令不需要加/d参数,加上就报错,cmd里的cd命令最好规规矩矩加上/d命令,切记 6、ls,列出目录下的文件,也可以用dir 7、get-item filename,get-item可以简写gi,获取文件属性,支持通配符 get-item ...
使用-ComputerName 参数可以访问远程计算机上的注册表。 powershellCopy Code # 访问远程计算机的注册表 Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name "ProductName" -ComputerName "RemoteComputerName" 12. 注册表路径的转义 在PowerShell 中,注册表路径使用的是反斜杠 \,如果...
Restart-Computer Stop-Computer 若要查找具有 ComputerName 参数的所有 cmdlet,请键入: PowerShell Get-Help*-ParameterComputerName# orGet-Command-ParameterNameComputerName 若要确定特定 cmdlet 的 ComputerName 参数是否需要 PowerShell 远程处理,请参阅参数说明。 若要显示参数说明,请键入: ...
Stop-Service : Service 'Windows Time (W32Time)' cannot be stopped due to the following error: Cannot open W32Time service on computer '.'. At line:1 char:1 + Stop-Service -Name W32Time + ~~~ + CategoryInfo : CloseError: (System.ServiceProcess.ServiceCon troller:ServiceController) [...
functionTest-MrParameter{param($ComputerName)Write-Output$ComputerName} 以下函数可查询系统中的所有命令,并返回带有特定参数名称的命令编号。 PowerShell functionGet-MrParameterCount{param( [string[]]$ParameterName)foreach($Parameterin$ParameterName) {$Results=Get-Command-ParameterName$Parameter-ErrorActionSil...
您可以使用ComputerName參數,從遠端電腦擷取相同的資訊,並指定電腦名稱或 IP 位址: PowerShell Get-CimClass-Namespaceroot/CIMV2-ComputerName192.168.1.29 遠端電腦傳回的類別清單可能會因為電腦執行的特定作系統而有所不同,而且已安裝的應用程式會新增特定的 WMI 擴充功能。
OK StatusInfo : SystemCreationClassName : Win32_ComputerSystem SystemName : lindexi SystemPaletteEntries : TimeOfLastReset : VideoArchitecture : 5 VideoMemoryType : 2 VideoMode : VideoModeDescription : 1920 x 1080 x 4294967296 种颜色 VideoProcessor : Intel(R) HD Graphics Family PSComputerName : ...
functionprompt {$Env:COMPUTERNAME+"\"+ (Get-Location) +"> "} 有关PowerShell 提示符的详细信息,请参阅about_Prompts。 有关其他配置文件示例,请参阅自定义 shell 环境。 NoProfile 参数 若要在没有配置文件的情况下启动 PowerShell,请使用的pwsh.exe参数(启动 PowerShell 的程序)。
ComputerName,Class LEE-DESK,Win32_OperatingSystem LEE-DESK,Win32_Bios PS >$data = Import-Csv WmiReport.csv PS >$data ComputerName Class ——— —– LEE-DESK Win32_OperatingSystem LEE-DESK Win32_Bios PS >$data | Foreach-Object { Get-WmiObject $_.Class -Computer $_.ComputerName } 2....