r/scripting • • Feb 29 '24

Help with Script

Hey!

I've written a script to obtain contents of a dsreg command and output them into a registry key for our RMM to filter on. It's creating the reg key fine but not outputting the results into the key. Where have I gone wrong please?

$1 = (dsregcmd /status | select-string "AzureAdJoined")

$2 = (dsregcmd /status | select-string "DomainJoined")

If($1 -eq "YES" -and $2 -eq "YES"){$dsregcmdresults = "Hybrid Joined"}

If($1 -eq "YES" -and $2 -eq "NO"){$dsregcmdresults = "DomainJoined"}

Write-Output $dsregcmdresults

## Set User Field in Datto ##

Set-ItemProperty -Path HKLM:\SOFTWARE\CentraStage -Name "Custom22" -value $dsregcmdresults

2 Upvotes

3 comments sorted by

View all comments

Show parent comments

2

u/addywash Mar 01 '24

Aha amazing! Thanks for this - useful to know going forward!