Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. <#
  2. .EXAMPLE
  3. Write-RegistryValue -Path "HKCU:\Software\Sysinternals\Strings" -Name "EulaAccepted
  4. #>
  5.  
  6. function Write-RegistryValue{
  7. param (
  8. [parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]$Path,
  9. [parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]$Name,
  10. [parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]$Value
  11. )
  12. Try{
  13. If (!(Test-Path $Path)){
  14. New-Item -Path (Split-Path $Path) -Name (Split-Path $Path -Leaf) -Force | Out-Null
  15. }
  16. Set-ItemProperty $Path -Name $Name -Value $Value
  17. Return $True
  18. }Catch{
  19. Return $False
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement