Tuesday, April 21, 2015

sample prompt

title = "Continue?"
$message = "If the settings are correct, Press Y to Continue?"
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Yes"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "No"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$choice=$host.ui.PromptForChoice($title, $message, $options, 1)

if ($choice -eq 1){Write-Warning "You pressed no.  Exiting script routine.";break}
Else { 'Do something Special }

Use User Credentials in MDT 2013 to Run Powershell Script

#UserName
$tmpuser=$tsenv:UserID
$tmpuser=[System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String($tmpuser))

#DomainName
$tmpdomain=$tsenv:UserDomain
$tmpdomain=[System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String($tmpdomain))

#set password to variable
$tmppassword=$tsenv:UserPassword

#Decode Password
[string]$tmppassword=[System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String($tmppassword))

#Convert to secure string
$mypassword=ConvertTo-SecureString -String $tmppassword -AsPlainText -Force

#format domainname\username for PSCredential object
[string]$tmpFQusername=$tmpdomain + "\" + $tmpuser

$creds = new-object System.Management.Automation.PSCredential($tmpFQusername,$mypassword)


Place the above code into your custom scripts to use PScredentials

Monday, April 13, 2015

Living List of Hotfixes for various components at Microsoft.

List of Failover Cluster related hotfixes post RTM for Windows Server 2012 R2 RTM