Archive for the 'PowerShell' Category

How to determine Powershell version and run an older Powershell Version

To get the powershell version run:


To run another version of powershell run for example:
powershell -version 2.0

No Comments »

admin on July 24th 2013 in IT, PowerShell

Install SNMP with Powershell on Windows 2012

If you run the command without the management tools then you won’t have the tabs to configure the snmp-service. By the way the argument –Whatif shows you in advance what would be installed if you run the command. So to actually installe it run the command without –WhatIf.

#Add-WindowsFeature -Name SNMP-Service -IncludeAllSubFeature -IncludeManagementTools –Restart –WhatIf

No Comments »

admin on June 4th 2013 in IT, PowerShell, Windows Server

PowerShell List Commands

Show-Command opens a new dialog where you can browse comfortably trough all commands.


No Comments »

admin on March 1st 2013 in IT, PowerShell, Windows Server

PowerShell View LogFiles from a Server

You can use the Get-EventLog. Example:
Get-EventLog -LogName Application -Source "*Update*" | Format-List
Get-EventLog -LogName Application –Newest 10

No Comments »

admin on February 11th 2013 in IT, PowerShell

Remote Session Powershell

Like ssh you can run a remote session in powershell.

Test if remote session is enabled
#Test-WsMan [Computername]

If you get a result, it should be up and running. Otherwise you need to activate it on the remote server like this.

Enable PowerShell Remoting on a Server
1. Run Powershell as an administrator
2. #Enable-PSRemoting –Force
This command starts the WinRM server service and sets it automatically to start with the system. It also creates a firewall rule that allows incoming connections.

If your computers aren’t in a domain you need to do a couple of more steps to make a trust between them. You need to edit the TrustedHosts on both sides. You could put the IP Adresses comma-seperated instead of * to further restrict it. With the * it will allow any host.

1. #Set-Item wsman:\localhost\client\trustedhosts *
2. #Restart-Service WinRM

Execute a Remote Command
#Invoke-Command -ComputerName COMPUTER -ScriptBlock { COMMAND } -credential USERNAME

Start a Remote Session
#Enter-PSSession -ComputerName COMPUTER -Credential USERNAME

No Comments »

admin on February 8th 2013 in PowerShell

Search for files and copy the result somewhere

Get-ChildItem -r *lana*.mp3 | Copy-Item -destination D:\Lana

No Comments »

admin on February 1st 2013 in PowerShell

Recursive Search Powershell

Short example:
dir –R –I *.exe

Long one:
Get-ChildItem -recurse –include *.exe

Search inclusive text:Get-ChildItem -recurse *.exe | Select-String searchtext

No Comments »

admin on November 27th 2012 in IT, PowerShell

Error 2738. Could not access VBScript run time for custom action.

Today i tried to install VMWare vSphere PowerCLI and got the vbscript error message.

Follow this steps to solve the problem:

1. Create a backup
2. Delete following registry entries:

Win32 Bit

Win64 Bit

3. Run CMD as an Administrator
4. regsvr32 vbscript.dll
5. regsvr32 jscript.dll

No Comments »

admin on June 4th 2012 in IT, PowerShell, Windows


Powershell is awesome.

Here a collection of some snippets:

Check who is accessing a file on a server:
net file | where {$_ –match “$filename”}

Get-Service | Sort-Object -Descending Status | ForEach{if($_.Status
-eq “Running”){Write-Host $_.Name -ForegroundColor green} else {Write-Host $_.Na
me -ForegroundColor red}}

Get-Service | ConvertTo-Html -Property Name, Status | ForEach {if($_
-like “*<td>Running</td>*”) {$_ -replace “<tr>”, “<tr bgcolor=green>”} else {$_
-replace “<tr>”, “<tr bgcolor=red>”}} > .\get-service.html

Get-PSDrive | Sort-Object Used -Descendind

New-PSDrive -name FK -psprovider FileSystem -root C:\Temp\Powershell\Files

Set-Location FK:
Get-ChildItem * -Exclude *.tmp, *.temp | Select-Object name, length | Sort-Object Length, Name -Descending

Get-Alias | Sort-Object

Get-Service | Group-Object Status
Get-Service | Get-Member
Get-Service | where{$_.status -eq “stopped”}

Get-ChildItem | Group-Object Extension | Sort-Object Count -Descending
Get-ChildItem | Measure-Object length -average -sum -maximum -minimum
Get-ChildItem | where-object{$_.length -gt 2MB}
Get-ChildItem | where {$_.PSIsContainer}

$a=Get-ChildItem | Select-Object Extension | Sort-Object Extension -unique
$a | ForEach {“.\Neu”+$_.Extension} | ForEach {NewItem $_ -type directory}

$a=Get-ChildItem | where {$_.PsIsContainer -eq -0}
$a | foreach{Copy-Item $_.FullName (“.\Neu” + $_.Extension + “\” + $_.Name)}

Get-ChildItem | foreach{$_.IsReadOnly = -1}

Get-ADUser -Filter *
Get-Command *user*

No Comments »

admin on May 16th 2012 in PowerShell

How to output PowerShell Command into a Textfile

Simply add this to your command:
| out-File Path$

No Comments »

admin on July 8th 2011 in IT, PowerShell

Check out new movies online website. Download and buy movies now.