Showing tag results for PowerTip

Aug 17, 2012
Post comments count0
Post likes count0

PowerTip: Working with Alternate Credentials with WMI

Doctor Scripto

Summary: Learn four  ways to supply alternate credentials with WMI and Windows PowerShell.  How can I supply alternate credentials for a remote WMI call when I am using the Get-WmiObject cmdlet? a. Use the credential parameter as shown here. Get-WmiObject Win32_BIOS -ComputerName Server01 -Credential (get-credential ` Domain01@...

Scripting Guy!Windows PowerShellPowerTip
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 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 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
Aug 13, 2012
Post comments count0
Post likes count0

PowerTip: Querying Active Directory via PowerShell

Doctor Scripto

Summary: Learn how to query Active Directory via Windows PowerShell.  Can you name five ways to query Active Directory from within Windows PowerShell?

Scripting Guy!Windows PowerShellPowerTip