Test/System/ElevateScript.ps1
Import-Module CmxModule -Force # This code enforces the "Elevate dialog" if the script has no been elevated yet. if (-not (IsElevated)) { $thisFile = $myinvocation.MyCommand.Definition Start-Process powershell.exe -Verb RunAs -ArgumentList "`"$thisFile`" $args" exit } # This code is executed only when the user has answered the "Elevate dialog" with yes. Write-Output "Script is running with admin rights at this moment . . . " Write-Output "The argument list:" for ($i=0; $i -lt $Args.Count; $i++){ Write-Output "Arg $i = $($Args[$i])" } Read-Host "Exit script ? " |