Showing archive results for August 2012

Aug 16, 2012
Post comments count0
Post likes count0

PowerTip: Adding a Default Exit to a PowerShell Switch

Doctor Scripto

Summary: Learn how to add a default exit condition to a Windows PowerShell switch statement to control execution of commands. I have the following switch statement, and I want to prevent the line Write-Host “switched” from executing? How can I do this? $a = 3 switch ($a) {  1 { "one detected" }  2 { "two de...

Scripting Guy!Windows PowerShellPowerTip
Aug 16, 2012
Post comments count0
Post likes count0

Use PowerShell to Query AD DS and Not Use LDAP Dialect

Doctor Scripto

Summary: Learn how to use the Filter parameter and the Windows PowerShell Expression Language on the Active Directory module cmdlets.  Hey, Scripting Guy! I do not know why you like ADSI so much. The syntax is obscure, and it makes things hard to read. Yesterday’s blog that used Get-ADComputer could have been so much better if you had le...

Scripting Guy!Windows PowerShellActive Directory
Aug 15, 2012
Post comments count0
Post likes count0

PowerTip: The Finer Points of Finessing an Array

Doctor Scripto

Summary: Learn how to replace items in an array and how to sort an array. I need to replace the “2” with “12” in the $array variable shown here: $array = "1","2","3","4" How can I do this?   I have an array defined in the $array variable shown here. $array = 2,5,9,12,3,5 What is the easiest way ...

Scripting Guy!Windows PowerShellPowerTip
Aug 15, 2012
Post comments count0
Post likes count0

Use PowerShell to Query AD DS for Servers and then Find Hotfixes

Doctor Scripto

Summary: Microsoft Scripting Guy, Ed Wilson, talks about querying the AD DS module via PowerShell and using the results to find hotfixes.  Hey, Scripting Guy!  We have a server running Windows Server 2008 R2 that is acting as one of our domain controllers. I do not have access to install the Remote Server Administration Tools (R...

Scripting Guy!Windows PowerShellActive Directory
Aug 14, 2012
Post comments count0
Post likes count0

PowerTip: Formatting Numeric Output Using PowerShell

Doctor Scripto

Summary: Learn how to format numeric output in Windows PowerShell by using format specifiers and numeric constants.  How can I print the amount of free space on a fixed disk in MB with two decimal places?  Use a format specifier as shown here: "{0:n2}"-f ((gwmi win32_logicaldisk -Filter "drivetype='3'").freespace/1MB)  What if I...

Scripting Guy!Windows PowerShellPowerTip