Browse by Tags

Tagged Content List
  • Blog Post: PowerTip: Retrieving Specific Items from Hash Table

    Summary : Retrieve specific items from a Windows PowerShell hash table. How can I use Windows PowerShell t retrieve specific values associated with specific keys in a hash table? Suppose you have a hash table such as this: $d = @{a=28;b=29;c=30} The keys and values associated with the hash...
  • Blog Post: PowerShell and Active Directory Recycle Bin

    Summary : Guest blogger, Alan Kaplan, talks about using Windows PowerShell with the Active Directory Recycle Bin. Microsoft Scripting Guy, Ed Wilson, is here. Today we have a guest blog post written by Alan Kaplan. I met Alan several years ago when the Scripting Wife and Jim Christopher started the...
  • Blog Post: PowerTip: Find Syntax for Related PowerShell Cmdlets

    Summary : Easily find the syntax for related Windows PowerShell cmdlets. How can I easily find the syntax for related Windows PowerShell cmdlets with the least effort? Use the Get-Command cmdlet, select the noun, and use the –syntax switch, for example: Get-Command -Noun csv -Syntax
  • Blog Post: PowerTip: Display Keys from Hash Table

    Summary : Learn how to display keys from a hash table. How can I display only the keys in a Windows PowerShell hash table? Store the hash table in a variable, and then use the Keys property, for example: $a = @{a=1;b=2;c=3;d=4} $a.Keys
  • Blog Post: PowerTip: Find Current Working Directory in PowerShell

    Summary : Easily find your current working directory in Windows PowerShell. I saved a file to my current working directory while I was working in the Windows PowerShell console, but I am not sure how to find where the file is. Use the Convert-Path cmdlet and specify a period ( . ). It displays...
  • Blog Post: PowerTip: Use PowerShell to Assess Memory Requirements

    Summary : Use Windows PowerShell to assess memory requirements. How can I use Windows PowerShell to figure out the minimum, maximum, and average working set requirements for processes on my workstation? Use the Get-Process cmdlet to return the working set information. Select the working set and...
  • Blog Post: PowerTip: Use PowerShell and Graphical Tool to View Files

    Summary : Use Windows PowerShell and a graphical tool to view large files. How can I use Windows PowerShell to easily see what files in a folder are the largest so I can clean up my file system? Use the Get-ChildItem cmdlet to return the contents of a folder, select the name and length of the files...
  • Blog Post: PowerTip: Read First Line of File with PowerShell

    Summary : Learn how to read only the first line of a file by using Windows PowerShell. How can I use Windows PowerShell to read only the first line of a file? Introduced in Windows PowerShell 3.0, you can use the -First parameter, for example: Get-Content C:\fso\batteryReport.txt -First 1
  • Blog Post: PowerTip: Display Hidden Properties from Object

    Summary : Learn how to use Windows PowerShell to display hidden properties from an object. How can I see if there are any hidden properties on an object I have returned from Windows PowerShell? Use the -Force parameter with either Format-List or Format-Table , for example: Get-ChildItem C: ...
  • Blog Post: PowerTip: Find all Format*xml Files Referencing WMI Class

    Summary : Find all Format*xml files that contain references to specific WMI class. I am trying to find why a particular WMI class returns a subset of properties. I suspect output is controlled by an entry in one of the Format*xml files, so how can I use Windows PowerShell to easily find which file...
  • Blog Post: PowerTip: Display Message in 16 Colors

    Summary : Use Windows PowerShell to display a message in 16 colors. How can I use Windows PowerShell to easily display a message in 16 different colors to start my presentation with something a little different? Use the range operator to create 16 numbers. Pipe the numbers to the Foreach-Object...
  • Blog Post: PowerTip: Cause PowerShell to Wait for Specific Event

    Summary : Cause Windows PowerShell to wait for a specific event to be generated. How can I make my Windows PowerShell console halt until an event that I registered by using the Register-CimIndicationEvent cmdlet occurs? Use the Wait-Event cmdlet and specifiy the source identifier. For example,...
  • Blog Post: PowerTip: Find Extended Type Data in PowerShell Session

    Summary : Find extended type data in your current Windows PowerShell session. How can I find out what extended type data exists in my current Windows PowerShell session? Use the Get-TypeData cmdlet.
  • Blog Post: PowerTip: Change Value of Element in Array with PowerShell

    Summary : Learn how to use Windows PowerShell to change the value of an element in an array. How can I use Windows PowerShell to update one of the values in one of the elements of an array? Use the Item method to retrieve the element and assign a new value. Here is an example of updating the value...
  • Blog Post: Use PowerShell to Start a Process at Random Times

    Summary : Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to start a process at random intervals. Hey, Scripting Guy! I have a rather unusual request. I am testing a new monitoring application, and I need a script that will start processes at random intervals so I can check...
  • Blog Post: PowerTip: Use PowerShell to Find Path for Processes

    Summary : Use Windows PowerShell to find the path of the executable for running processes. I noticed a process and I am unsure of what it does. How can I use Windows PowerShell to find more information? Look at the path to the executable to find information about a process. If it is legitimate...
  • Blog Post: Weekend Scripter: The WMI Explorer Tool

    Summary : Guest blogger, Vinay Pamnani, talks about a cool new WMI tool. Microsoft Scripting Guy, Ed Wilson, is here. One of the absolutely greatest things about working for Microsoft is the chance to meet (even virtually) and interact with really smart people who absolutely love technology. I recently...
  • Blog Post: PowerTip: Find Array Members with Get-Member in PowerShell

    Summary : Learn to find members of an array with the Get-Member cmdlet in Windows PowerShell. I have an array of numbers: 1,2,3,4,5 that I assigned to variable $a . When I pipe it to Get-Member: $a | gm , all I see are members for int32 . How can I find the members of an array by using Get-Member...
  • Blog Post: Why Are All These Services Starting?

    Summary : Microsoft Scripting Guy, Ed Wilson, talks about using WMI to find out how services start. Hey, Scripting Guy! I was looking at the processes on my workstation, and I see lots of things running. I suspect many of these are actually services. But I am wondering how I can use Windows PowerShell...
  • Blog Post: PowerTip: Find WMI Classes Related to Services

    Summary : Use Windows PowerShell to find WMI classes related to services that reveal start mode. How can I use Windows PowerShell to find a WMI class that will help me identify how services are starting? Use the Get-CimClass cmdlet, use a wildcard character for the name, and specify StartMode as...
  • Blog Post: PowerTip: Use PowerShell to Cast to WMI UInt Value Type

    Summary : Use Windows PowerShell to cast to the WMI UInt value type. I am comparing data from WMI, and it seems strange. I found the value type is a UInt32 , and when I looked it up, I found that it is an unsigned 32-bit integer . How can I use Windows PowerShell to create one of these? Use [uint32...
  • Blog Post: PowerTip: Find WMI Classes by Using PowerShell

    Summary : Use Windows PowerShell to find WMI classes. I am searching for a WMI class to help me find information about Windows startup configuration. I am unsure of the class name. How can I use Windows PowerShell to help me find the class (assuming it exists)? Use the Get-CimClass CIM cmdlet that...
  • Blog Post: PowerTip: Find Value from PowerShell Hash Table

    Summary : Look up values from a Windows PowerShell hash table. How can I look up a specific value that is associated with a specific key in a Windows PowerShell hash table? Use the Item method and supply the key, for example: $hash = @{ 2 = "Removable disk" 3="Fixed local...
  • Blog Post: PowerTip: Use Tab to Complete WMI Class Names

    Summary : Use Tab completion to type WMI class names in Windows PowerShell. I am using WMI in the Windows PowerShell console and in the Windows PowerShell ISE, and I am having a hard time correctly typing the long convoluted class names. How can I simplify the process and be more accurate? Use...
  • Blog Post: PowerTip: New Lines with PowerShell

    Summary : Create new lines with Windows PowerShell. How can I use Windows PowerShell to add a new line between lines for my text output? Use the `n character, for example: PS C:\> "string with new line `n in it" string with new line in it Note If you need a carriage return...