Category Archive: PowerShell

Apr 09

How to: Find the HP Product Number of all your HP server using powershell

You can easly find the HP product number of any of your HP server by looking on the server itself or on the warranty card. The HP product number is nice to have if you want to easily find that date your HP server will be out of warranty. This product number is no longer …

Continue reading »

Apr 02

Powershell Tips of the week #4 – Get-ChildItem – Only show directories

Here’s quick tip on how to make Get-ChildItem only return directories. With Powershell v3, there is a new parameter that allow you to only get directories: Get-ChildItem C:\ -directory Result: Directory: C:\ Mode                LastWriteTime     Length Name —-                ————-   …

Continue reading »

Mar 25

Powershell Tips of the week #3 – Find parent folder

How to find the parent folder of a path that is stored in a variable For the purpose of the example I will manually add a path to a variable. $VarA = "\\\dfs\files\dan.fortier\" The parent folder of this path is “\\\dfs\files” but lets find it with powershell using the Get-Item cmdlet. $ParentFolder = (Get-Item $VarA).parent.FullName …

Continue reading »

Mar 19

Powershell Tips of the week #2 – Measure-Command

In today’s post I will talk about the Measure-Command function in Powershell. This function will tell you exactly how much time it took to run a cmdlet or a script block. The result will be displayed like this: Days              : 0 Hours             : …

Continue reading »

Mar 14

Powershell Tips of the week #1 – Cmdlet Start-Transcript

This week I will show you how to use the Start-Transcript cmdlet. Start-Transcript will allow you to record your powershell session in a text file. The transcript includes all command that the user types and all output that appears on the console. Here is some example on how to use Start-Transcript: This command starts a …

Continue reading »

Oct 01

How to: List members of the Administrators local group

This is a simple powershell script that will list all the members in the Administrators local group. Just add all the computer name in C:\Servers.txt. $Computers = Get-Content "C:\servers.txt" foreach ($Computer in $Computers) {     $strcomputer = [ADSI]("WinNT://" + $Computer + ",computer")     $Group = $strcomputer.psbase.children.find("Administrators")     $members= $Group.psbase.invoke("Members") | %{$_.GetType().InvokeMember("Name", ‘GetProperty’, …

Continue reading »

Jul 30

How To: Get serial number from a list of servers or computers

Description: This How To will help you get the serial number from a list of servers or computers. The list of servers or computers would be provide in a txt file. Prerequisite: Microsoft PowerShell 1.0 or higher   How To: $colItems = get-wmiobject -class "Win32_BIOS" -computername (Get-Content c:\computers.txt) foreach ($objItem in $colItems) {    $computername …

Continue reading »

Older posts «