Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

trying to compare regestry

$
0
0

Im trying to give a computer  usb exception but in my company some users already have USB exception what  im trying to do is add a "if" statement to tell me if the user is already set up with usb exception and then i want it to verify it both registry equal one another 

 

$registry= cd HKLM:SYSTEM\CurrentControlSet\Control\StorageDevicePolicies writeprotect -Value 0

$machine= Read-Host "what machine would you like to give usb exception too" 

Invoke-Command -ComputerName $machine

if  ($registry -ne  "HKLM:SYSTEM\CurrentControlSet\Control\StorageDevicePolicies writeprotect -Value 0")

{

    Set-ItemProperty -Path  SYSTEM\CurrentControlSet\Control\StorageDevicePolicies writeprotect -Value 0

else {"user has usb exception"}

if  ($registry -eq  "HKLM:SYSTEM\CurrentControlSet\Control\StorageDevicePolicies writeprotect -Value 0")

 {"$machine already had usb exception"}


Viewing all articles
Browse latest Browse all 6937

Trending Articles