- <#
- .SYNOPSIS
- MSDN Sample Recoded in PowerShell demonstrating formatting
- .DESCRIPTION
- This sample recodes an MSDN Sample into PowerShell that
- shows some of the options of formatting using ToString() and
- various .NET formatting strings
- .NOTES
- File Name : Show-Formatting1.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
- .EXAMPLE
- Psh> .\Show-Formatting1.ps1\
- 00123
- 1.20
- 01.20
- 01,20
- 0.6
- 1,234,567,890
- 1.234.567.890
- 1,234,567,890.1
- 1,234.57
- #>
- ## Start script
- [double] $value = 123;
- $value.ToString("00000")
- # Displays 00123
- $value = 1.2;
- $value.ToString("0.00", [System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 1.20
- $value.ToString("00.00",[System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 01.20
- $value.ToString("00.00",
- [System.Globalization.CultureInfo]::CreateSpecificCulture("da-DK"))
- # Displays 01,20
- $value = .56
- $value.ToString("0.0", [System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 0.6
- $value = 1234567890
- $value.ToString("0,0", [System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 1,234,567,890
- $value.ToString("0,0",
- [System.Globalization.CultureInfo]::CreateSpecificCulture("el-GR"))
- # Displays 1.234.567.890
- $value = 1234567890.123456;
- $value.ToString("0,0.0", [System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 1,234,567,890.1
- $value = 1234.567890;
- $value.ToString("0,0.00", [System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 1,234.57
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Tuesday, 7 August 2012
Show-Formatting1.ps1
Thursday, 5 July 2012
Manage-ServerCoreGui.ps1
- <#
- .Synopsis
- This file contains two simple functions to manage the GUI
- in Server Core Windows Server 2012.
- .DESCRIPTION
- There are two functions: Enable-ServerCoreGui that enables
- the GUI in a server core installation. Diable-ServerCoreGuI
- disables the GUI and returns the installation to
- traditional Server Core.
- Enable-ServerCoreGui also checks to see if some or all
- parts are already installed andwarns accordingly.
- .EXAMPLE
- c:\foo> Enable-ServerCoreGui
- This enables the GUI and reboots the Server into FUll GUI mode.
- .EXAMPLE
- c:\foo> Disable-ServerCoreGui
- This disables the GUI and reboots the Server back to Server Core mode.
- #>
- Function Enable-ServerCoreGui {
- # Import the module
- Import-Module -Name DISM -ErrorAction Stop
- # is it already enabled??
- if ((Get-WindowsOptionalfeature -online -Feature ServerCore-FullServer).state -eq 'Enabled'){
- "Servercore-FullServer is already enabled"
- }
- if ((Get-WindowsOptionalfeature -online -Feature Server-GUI-Shell).state -eq 'Enabled'){
- "Server-GUI Shell is already enabled"
- }
- if ((Get-WindowsOptionalfeature -online -Feature Server-Gui-Mgmt).state -eq 'Enabled'){
- "Server-Gui-Mgmt is already enabled"
- }
- # Enable the features needed to add the GUI
- Enable-WindowsOptionalFeature –Online -NoRestart `
- -Featurename ServerCore-FullServer, Server-Gui-Shell,Server-Gui-Mgmt
- # So Restart the computer
- Restart-computer
- }
- Function Disable-ServerCoreGui {
- # Import the module
- Import-Module -Name DISM -ErrorAction Stop
- # Disable all the features needed to add the GUI
- # if any are already disabled, oh well - they're still disabled.
- Disable-WindowsOptionalFeature –Online -NoRestart `
- -Featurename ServerCore-FullServer, Server-Gui-Shell,Server-Gui-Mgmt
- # Finally Restart the computer
- Restart-computer
- }
Monday, 30 April 2012
Show-DnsConfiguration.ps1
- <#
- .SYNOPSIS
- This script shows the DNS Configuration of NICs
- in your system
- .DESCRIPTION
- This script is a re-write of an MSDN Sample
- using PowerShell./ The script gets all network
- active network interfaces then prints out that
- interfaces' DNS Properties.
- .NOTES
- File Name : Show-DnsConfiguration.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getallnetworkinterfaces.aspx
- .EXAMPLE
- Psh[C:\foo]> .\Show-DnsConfiguration.ps1
- Broadcom NetXtreme 57xx Gigabit Controller
- DNS suffix .............................. : cookham.net
- DNS enabled ............................. : False
- Dynamically configured DNS .............. : True
- ... more interfaces snipped for brevity!
- #>
- # Get the adapters than iterate over the collection and display DNS configuration
- $adapters = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()
- ForEach ($adapter in $adapters) {
- $properties = $adapter.GetIPProperties()
- $adapter.Description
- " DNS suffix .............................. : {0}" -f $properties.DnsSuffix
- " DNS enabled ............................. : {0}" -f $properties.IsDnsEnabled
- " Dynamically configured DNS .............. : {0}" -f $properties.IsDynamicDnsEnabled
- }
Show-NetworkInterfaces2.ps1
- <#
- .SYNOPSIS
- This script, shows details about the Network Interfaces
- on a system. This is a re-write of an MSDN script into
- PowerShell
- .DESCRIPTION
- This script Uses several .NET classes to get the details
- of the interfaces on the system, then displays these details.
- Note in the MSDN Script, there were calls to other MSDN Samples.
- To make things simple, I have removed these calls.
- .NOTES
- File Name : Show-NetworkInterfaces2.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.aspx
- .EXAMPLE
- Psh[C:\foo]> .\Show-NetworkInterfaces2.ps1
- Interface information for Cookham8.cookham.net
- Number of interfaces .................... : 2
- Broadcom NetXtreme 57xx Gigabit Controller
- ==========================================
- Interface type .......................... : Ethernet
- Physical Address ........................ : 001E4F955CC4
- Operational status ...................... : Up
- IP version .............................. : IPv4, IPv6
- DNS suffix .............................. : cookham.net
- MTU...................................... : 1500
- WINS Servers ............................ :
- 10.10.1.101
- DNS enabled ............................. : False
- Dynamically configured DNS .............. : True
- Receive Only ............................ : False
- Multicast ............................... : True
- Microsoft ISATAP Adapter
- ========================
- Interface type .......................... : Tunnel
- Physical Address ........................ : 00000000000000E0
- Operational status ...................... : Down
- IP version .............................. : IPv4, IPv6
- DNS suffix .............................. : cookham.net
- MTU...................................... :
- DNS enabled ............................. : False
- Dynamically configured DNS .............. : True
- Receive Only ............................ : False
- Multicast ............................... : False
- #>
- # First, get network properties of, and the nics in, this system
- $computerProperties = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()
- $nics = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()
- "Interface information for {0}.{1}" -f $computerProperties.HostName, $computerProperties.DomainName
- # Do we have nics??
- If (!$nics -or $nics.Length -lt 1)
- {
- " No network interfaces found."
- return
- }
- # Show interface details
- " Number of interfaces .................... : {0}" -f $nics.Length
- ForEach ($adapter in $nics)
- {
- $properties = $adapter.GetIPProperties()
- ""
- $adapter.Description
- "=" * $adapter.Description.Length
- " Interface type .......................... : {0}" -f $adapter.NetworkInterfaceType
- " Physical Address ........................ : {0}" -f $adapter.GetPhysicalAddress().ToString()
- " Operational status ...................... : {0}" -f $adapter.OperationalStatus
- # Create a display string for the supported IP versions.
- $versions =""
- if ($adapter.Supports([System.Net.NetworkInformation.NetworkInterfaceComponent]::IPV4 ))
- {
- $versions = "IPv4"
- }
- if ($adapter.Supports([System.Net.NetworkInformation.NetworkInterfaceComponent]::IPv6))
- {
- if ($versions.Length -gt 0)
- {
- $versions += ", ";
- }
- $versions += "IPv6";
- }
- " IP version .............................. : {0}" -f $versions
- # The remaining information is not useful for loopback adapters.
- if ($adapter.NetworkInterfaceType -eq [System.Net.NetworkInformation.NetworkInterfaceType]::Loopback)
- {
- continue
- }
- " DNS suffix .............................. : {0}" -f $properties.DnsSuffix
- if ($adapter.Supports([System.Net.NetworkInformation.NetworkInterfaceComponent]::IPv4))
- {
- $ipv4 = $properties.GetIPv4Properties()
- " MTU...................................... : {0}" -f $ipv4.Mtu
- if ($ipv4.UsesWins)
- {
- $winsServers = $properties.WinsServersAddresses
- if ($winsServers.Count -gt 0)
- {
- " WINS Servers ............................ :";
- foreach ($Winserver in $winsServers) {
- " {0}" -f $Winserver.IpAddressToString
- }
- }
- }
- }
- " DNS enabled ............................. : {0}" -f $properties.IsDnsEnabled
- " Dynamically configured DNS .............. : {0}" -f $properties.IsDynamicDnsEnabled
- " Receive Only ............................ : {0}" -f $adapter.IsReceiveOnly
- " Multicast ............................... : {0}" -f $adapter.SupportsMulticast
- } # End Foreach
Sunday, 29 April 2012
Show-NetworkInterfaces1.ps1
- <#
- .SYNOPSIS
- This script displays the NICs in a system and their physical
- address.
- .DESCRIPTION
- This script is a MSDN Sample recoded in PowerShell. The script
- first gets all the interfaces on the system, then loops through
- them displaying more information about them to the console.
- Note the use of Console.Write in the loop at the end. Not quite
- sure a better PowerShell equivalent other than creating a
- string with all the bytes, then displaying that string.
- .NOTES
- File Name : Show-NetworkInterfaces1.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library/system.net.networkinformation.physicaladdress.aspx
- .EXAMPLE
- PSH[c:\foo]> .\Show-Networkinterfaces1.ps1
- Interface information for Cookham8.cookham.net
- Number of interfaces .................... : 2
- Broadcom NetXtreme 57xx Gigabit Controller
- ==========================================
- Interface type .......................... : Ethernet
- Physical address ........................ : 00-1E-4F-95-5C-C4
- Microsoft ISATAP Adapter
- ========================
- Interface type .......................... : Tunnel
- Physical address ........................ : 00-00-00-00-00-00-00-E0
- #>
- # Get computer IP global properties
- $ComputerProperties = [System.Net.NetworkInformation.IpGlobalProperties]::GetIPGlobalProperties()
- # Get the nics in this system
- $nics = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()
- # Show information header
- "Interface information for {0}.{1} " -f $ComputerProperties.HostName, $ComputerProperties.DomainName
- # Iterate through the NIcs ans outout per nic info
- # First, check if interfaces are found
- if (!$nics -OR $nics.Length -LT 1)
- {
- " No network interfaces found."
- return
- }
- # Here print out number of interfaces and interface details
- [System.Console]::WriteLine(" Number of interfaces .................... : {0}" -f $nics.Length)
- Foreach ($adapter in $nics)
- {
- $properties = $adapter.GetIPProperties();
- " ";""
- "{0}" -F $adapter.Description
- "=" * $adapter.Description.Length
- " Interface type .......................... : {0}" -F $adapter.NetworkInterfaceType
- [System.Console]::Write(" Physical address ........................ : ")
- $address = $adapter.GetPhysicalAddress();
- $bytes = $address.GetAddressBytes()
- for($i = 0; $i -lt $bytes.Length; $i++)
- {
- # Display the physical address in hexadecimal.
- [system.Console]::Write("{0}" -f $bytes[$i].ToString("X2"))
- # Insert a hyphen after each byte, unless we are at the end of the
- # address.
- if ($i -NE $bytes.Length -1)
- {
- [System.Console]::Write("-")
- }
- }
- [System.Console]::WriteLine()
- }
Sunday, 19 February 2012
Get-ProcessesAsExcel.ps1
- <#
- .SYNOPSIS
- This script creates an Excel workbook using PowerShell and
- populates it with the results of calling Get-Process and
- copying across the key properties
- .DESCRIPTION
- This script demonstrates manipulating Excel with PowerShell
- and the Excel.Application COM object.
- .NOTES
- File Name : .\Get-ProcessesAsExcel.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://pshscripts.blogspot.com/2012/02/get-processesasexcelps1.html
- .EXAMPLE
- Left as an exercise to the reader.
- #>
- ##
- # Start of Script
- ##
- # First, create and single worksheet workbook
- # Create Excel object
- $excel = new-object -comobject Excel.Application
- # Make Excel visible
- $excel.visible = $true
- # Create a new workbook
- $workbook = $excel.workbooks.add()
- # The default workbook has three sheets, remove 2,4
- $S2 = $workbook.sheets | where {$_.name -eq "Sheet2"}
- $s3 = $workbook.sheets | where {$_.name -eq "Sheet3"}
- $s2.delete()
- $s3.delete()
- # Get sheet and update sheet name
- $s1 = $workbook.sheets | where {$_.name -eq 'Sheet1'}
- $s1.name = "Processes"
- # Update workook properties
- $workbook.author = "Thomas Lee - Doctordns@gmail.com"
- $workbook.title = "Processes running on $(hostname)"
- $workbook.subject = "Demonstrating the Power of PowerShell with Excel"
- # Next update Headers
- $s1.range("A1:A1").cells="Handles"
- $s1.range("B1:B1").cells="NPM(k)"
- $s1.range("C1:C1").cells="PM(k)"
- $s1.range("D1:D1").cells="WS(k)"
- $s1.range("E1:E1").cells="VM(M)"
- $s1.range("F1:F1").cells="CPU"
- $s1.range("G1:G1").cells="ID"
- $s1.range("H1:H1").cells="Process Name"
- $row = 2
- Foreach ($Process in $(Get-Process)) {
- $s1.range("A$Row:A$Row").cells=$Process.handles
- $s1.range("b$Row:B$Row").cells=$Process.NPM
- $s1.range("c$Row:C$Row").cells=$Process.PM
- $s1.range("d$Row:D$Row").cells=$Process.WS
- $s1.range("e$Row:E$Row").cells=$Process.VM
- $s1.range("f$Row:F$Row").cells=$Process.CPU
- $s1.range("g$Row:G$Row").cells=$Process.ID
- $s1.range("h$Row:H$Row").cells=$Process.Name
- $row++
- }
- # And save it away:
- $s1.saveas("c:\foo\process.xlsx")
- # end of script
Tuesday, 7 February 2012
Test-FileOpen
- <#
- .SYNOPSIS
- This script defines a function that tests to
- see if a file is open.
- .DESCRIPTION
- This script used the System.Io.FileStream class
- and the FileInfo class to try to open a file
- stream for write. If it fails, we return $false,
- else we close the file and return $True
- .NOTES
- File Name : Test-FileOpen.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh[Cookham8:C:\foo]> $file = New-Object -TypeName System.IO.FileInfo C:\foo\doc1.docx
- Psh[Cookham8:C:\foo]>Test-FileOpen $file
- True
- #>
- Function Test-FileOpen {
- Param (
- $fileName = $(Throw '***** No File specified')
- )
- $ErrorActionPreference = "SilentlyContinue"
- [System.IO.FileStream] $fs = $file.OpenWrite();
- if (!$?) {$true}
- else {$fs.Dispose();$false}
- }
- # Test the function
- $file = New-Object -TypeName System.IO.FileInfo C:\foo\doc1.docx
- Test-FileOpen $file
Sunday, 22 January 2012
New-SpanishCulture.ps1
- <#
- .SYNOPSIS
- This script creates a Spanish cultureinfo object with a traditional
- sort and another with an international sort. The script then compares them.
- .DESCRIPTION
- This script re-implements an MSDN sample.
- .NOTES
- File Name : New-SpanishCulture.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
- .EXAMPLE
- C:\foo> .\New-SpanishCulture.ps1
- PROPERTY INTERNATIONAL TRADITIONAL
- CompareInfo CompareInfo - es-ES CompareInfo - es-ES_tradnl
- DisplayName Spanish (Spain) Spanish (Spain)
- EnglishName Spanish (Spain, International Sort) Spanish (Spain, Traditional Sort)
- IsNeutralCulture False False
- IsReadOnly False
- LCID 3082 1034
- Name es-ES es-ES
- NativeName Español (España, alfabetización internacional) Español (España, alfabetización tradicional)
- Parent es es
- TextInfo TextInfo - es-ES TextInfo - es-ES_tradnl
- ThreeLetterISOLanguageName spa spa
- ThreeLetterWindowsLanguageName ESN ESP
- TwoLetterISOLanguageName es es
- Comparing [llegar] and [lugar]
- With myCIintl.CompareInfo.Compare: -1
- With myCItrad.CompareInfo.Compare: 1
- #>
- # Create and initialize the CultureInfo which uses the international sort
- $myCIintl = New-Object System.Globalization.CultureInfo "es-ES", $false
- # Create and initialize the CultureInfo which uses the traditional sort
- $myCItrad = New-Object System.Globalization.CultureINfo 0x040A, $false
- # Display the properties of each culture.
- "{0,-31}{1,-47}{2,-25}" -f "PROPERTY", "INTERNATIONAL", "TRADITIONAL"
- "{0,-31}{1,-47}{2,-25}" -f "CompareInfo", $myCIintl.CompareInfo, $myCItrad.CompareInfo
- "{0,-31}{1,-47}{2,-25}" -f "DisplayName", $myCIintl.DisplayName, $myCItrad.DisplayName
- "{0,-31}{1,-47}{2,-25}" -f "EnglishName", $myCIintl.EnglishName, $myCItrad.EnglishName
- "{0,-31}{1,-47}{2,-25}" -f "IsNeutralCulture", $myCIintl.IsNeutralCulture, $myCItrad.IsNeutralCulture
- "{0,-31}{1,-47}{2,-25}" -f "IsReadOnly", $myCIintl.$IsReadOnly, $myCItrad.IsReadOnly
- "{0,-31}{1,-47}{2,-25}" -f "LCID", $myCIintl.LCID, $myCItrad.LCID
- "{0,-31}{1,-47}{2,-25}" -f "Name", $myCIintl.Name, $myCItrad.Name
- "{0,-31}{1,-47}{2,-25}" -f "NativeName", $myCIintl.NativeName, $myCItrad.NativeName
- "{0,-31}{1,-47}{2,-25}" -f "Parent", $myCIintl.Parent, $myCItrad.Parent
- "{0,-31}{1,-47}{2,-25}" -f "TextInfo", $myCIintl.TextInfo, $myCItrad.TextInfo
- "{0,-31}{1,-47}{2,-25}" -f "ThreeLetterISOLanguageName", $myCIintl.ThreeLetterISOLanguageName, $myCItrad.ThreeLetterISOLanguageName
- "{0,-31}{1,-47}{2,-25}" -f "ThreeLetterWindowsLanguageName",$myCIintl.ThreeLetterWindowsLanguageName, $myCItrad.ThreeLetterWindowsLanguageName
- "{0,-31}{1,-47}{2,-25}" -f "TwoLetterISOLanguageName", $myCIintl.TwoLetterISOLanguageName, $myCItrad.TwoLetterISOLanguageName
- ""
- # Compare two strings using myCIintl
- "Comparing [llegar] and [lugar]"
- " With myCIintl.CompareInfo.Compare: {0}" -f $myCIintl.CompareInfo.Compare("llegar", "lugar")
- " With myCItrad.CompareInfo.Compare: {0}" -f $myCItrad.CompareInfo.Compare("llegar", "lugar")
Show-ChineeseParentCulture.ps1
- <#
- .SYNOPSIS
- This script displays the parent culture of each
- specific culture using the Chinese language.
- .DESCRIPTION
- This script looks at each Chineese culture and displays
- the culture name and the parent.
- .NOTES
- File Name : Show-ChineeseParentCulture.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
- .EXAMPLE
- C:\foo> .\Show-ChineeseParentCulture.ps1
- SPECIFIC CULTURE PARENT CULTURE
- 0x0804 zh-CN Chinese (Simplified, PRC) 0x0004 zh-CHS Chinese (Simplified) Legacy
- 0x0C04 zh-HK Chinese (Traditional, Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) Legacy
- 0x1404 zh-MO Chinese (Traditional, Macao S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) Legacy
- 0x1004 zh-SG Chinese (Simplified, Singapore) 0x0004 zh-CHS Chinese (Simplified) Legacy
- 0x0404 zh-TW Chinese (Traditional, Taiwan) 0x7C04 zh-CHT Chinese (Traditional) Legacy
- #>
- # Display a header
- "SPECIFIC CULTURE PARENT CULTURE"
- # Determine the specific cultures that use the Chinese language, and displays the parent culture
- ForEach ($ci in [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::SpecificCultures)) {
- if ($ci.TwoLetterISOLanguageName -eq "zh")
- {
- $s1 = "0x{0} {1} {2,-40}" -f $ci.LCID.ToString("X4"), $ci.Name, $ci.EnglishName
- $s2 = "0x{0} {1} {2}" -f $ci.Parent.LCID.ToString("X4"), $ci.Parent.Name, $ci.Parent.EnglishName
- "{0}{1}" -f $s1, $s2
- }
- }
Friday, 30 December 2011
Show-MessageBox.ps1
- <#
- .SYNOPSIS
- This script displays a message box and then processes it
- .DESCRIPTION
- This script firsts creates a wscript.shell object and
- invokes the popup method to display a message. The script
- then processes the response to the geroup (timeout, yes, no).
- .NOTES
- File Name : Show-MessageBox.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted tot:
- http://msdn.microsoft.com/en-us/library/x83z1d9f%28VS.84%29.aspx
- .EXAMPLE
- Left as an exercise to the reader!
- #>
- # Create the shell object
- $WshShell = New-Object -Com Wscript.Shell
- # Call the Popup method with a 7 second timeout.
- $Btn = $WshShell.Popup("Do you feel alright?", 7, "Question:", 0x4 + 0x20)
- # Process the response
- switch ($Btn) {
- # Yes button pressed.
- 6 {"Glad to hear you feel alright."}
- # No button pressed.
- 7 {"Hope you're feeling better soon."}
- # Timed out.
- -1 {"Is there anybody out there?"}
- }
Subscribe to:
Posts (Atom)