# Function by Oliver Lipkau (https://devblogs.microsoft.com/scripting/use-powershell-to-work-with-any-ini-file/) function Get-IniContent ($filePath) { $ini = @{} switch -regex -file $FilePath { “^\[(.+)\]” # Section { $section = $matches[1] $ini[$section] = @{} $CommentCount = 0 } “^(;.*)$” # Comment { $value = $matches[1] $CommentCount = $CommentCount + 1 $name = “Comment” + $CommentCount $ini[$section][$name] = $value } “(.+?)\s*=(.*)” # Key { $name,$value = $matches[1..2] $ini[$section][$name] = $value } } return $ini } $File = "$env:SystemDrive\Personality.ini" if ( Test-Path $File ) { $iniContent = Get-IniContent $File; $value = $iniContent["StringData"]; } if ($value.values -eq "Private") {write-host "It's private";start-sleep 600;net stop netsetupsvc} else { write-host "Exit" exit-pssession }