# 示例:批量导出指定路径下的注册表项$regPath="HKCU:\Software\MyApp"$backupPath="C:\RegistryBackups"if(!(Test-Path-Path$backupPath)) {New-Item-ItemTypeDirectory-Path$backupPath}Export-Registry-Path$regPath-LiteralPath"$backupPath\MyAppRegistryBackup.reg" 注意事项: 在操作注册表时,始终备份重要的...
# 创建HKEY_CLASSES_ROOT快捷方式:New-PSDrive-NameHKCR-PSProviderregistry-rootHKEY_CLASSES_ROOT |Out-Null# 找出关联PS1文件的键,若没有则创建一个:if(!(Test-Path("HKCR:\.ps1"))){New-Item-ItemTypeString ("HKCR:\.ps1")-value"Powershell"$keyname= (Get-ItemPropertyHKCR:\.ps1)."(default)"New...
New-Item New-ItemProperty New-PSDrive New-Service Pop-Location Push-Location Remove-Item Remove-ItemProperty Remove-PSDrive Remove-Service Rename-Computer Rename-Item Rename-ItemProperty Resolve-Path Restart-Computer Restart-Service Resume-Service
$newItemPropertySplat= @{ Path ='HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion'Name ='PowerShellPath'PropertyType ='String'Value =$PSHome}New-ItemProperty@newItemPropertySplat Output PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion PSParentPath ...
Get-ItemProperty 读取键的值 Set-ItemProperty 设置键的值 New-ItemProperty 给键创建一个新值 Clear-ItemProperty 删除键的值内容 Remove-ItemProperty 删除键的值 New-Item, md 创建一个新键 Remove-Item, Del 删除一个键 Test-Path 验证键是否存在 注意:注册表几乎存储了Windows的核心配置。所以这也是它为什么成...
New-ItemProperty -Path 'HKCU:\Software\MyApp' -Name 'NewValue' -PropertyType String -Value 'Hello, World!' #删除注册表值:从指定路径下删除注册表值。 Remove-ItemProperty -Path 'HKCU:\Software\MyApp' -Name 'NewValue' #创建 DWord(32 位)注册表值:其中将 "注册表项路径" 替换为要创建值的注册...
如果要获取当前注册表项的属性值,可以利用Get-ItemProperty命令。 代码语言:javascript 复制 PSHKCU:\Control Panel\Desktop\MuiCached>Get-ItemProperty.MachinePreferredUILanguagesMachinePreferredUILanguages:{zh-CN}PSPath:Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Control Panel\Desktop\MuiCachedPSParentPa...
Set-ItemProperty [-Path] <string[]> [-Name] <string> [-Value] <Object> [-PassThru] [-Force] [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-Type <RegistryValueKind>] [<CommonParameters>] PowerShell コピー Set...
"Process Creation" $registryPath = @{ Path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Audit' } New-Item @registryPath $forceDwordOne = @{ PropertyType = 'DWord' Value = 1 Force = $True } New-ItemProperty @registryPath -Name 'ProcessCreationIncludeCmdLine_Enabled' ...
set$RegistryPath='HKCU:\Software\CommunityBlog\Scripts'$Name='Version'$Value='42'# Create the key if it does not existIf(-NOT(Test-Path$RegistryPath)) {New-Item-Path$RegistryPath-Force|Out-Null}# Now set the valueNew-ItemProperty-Path$RegistryPath-Name$Name-Value$Value-PropertyTypeDWORD-...