$message = "Do you want to start screensaver and lock the desktop after 30 minutes of inactivity?"
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", `
  "Starts screensaver and locks the desktop after 30 minutes of inactivity."
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", `
  "Does nothing."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $host.ui.PromptForChoice($title, $message, $options, 1)
switch ($result) {
  0 {
    $dir = 'HKCU:\Control Panel\Desktop'
    Set-ItemProperty $dir -Name ScreenSaveActive -Type String -Value 1
    Set-ItemProperty $dir -Name ScreenSaverIsSecure -Type String -Value 1
    Set-ItemProperty $dir -Name ScreenSaveTimeOut -Type String -Value 1800
  }
}
