Pages

Thursday, 25 May 2023

PSADT to create Form sample

    $proceed = 'No'

   $noClickCounter = 0


    while ($proceed -ne 'Yes') {

    $proceed = Show-DialogBox -Title 'Installation Notice' -Text 'Application is Installed, would you like to restart the machine?' -Buttons $([System.Windows.Forms.MessageBoxButtons]::YesNo) -DefaultButton 'First' -Icon 'Exclamation' -Topmost $true


    if ($proceed -eq 'No') {

        $noClickCounter++


        if ($noClickCounter -eq 3) {

            $proceed = Show-DialogBox -Title 'Installation Notice' -Text 'Application is Installed, would you like to restart the machine?' -Buttons $([System.Windows.Forms.MessageBoxButtons]::OK) -DefaultButton 'First' -Icon 'Exclamation' -Topmost $true

        Restart-Computer -Force

        }

        else {

            Sleep -Seconds 30

        }

    }

    elseif ($proceed -eq 'Yes') {

        Restart-Computer -Force

    }

}


User based detection

function getloggedindetails () {     ##Find logged in username     $user = Get-WmiObject Win32_Process - Filter "Name='explorer...

Search This Blog