Browsing "Powershell"

How can I suspend a VM on VMware workstation via Powershell ?

As there is no API for Powershell in VMware worksation, we need to use the built-in tool called ‘vmrun.exe”

This utility can be used to control virtual machines and allows the following operations: start (power on), stop (power off), reset (reboot), suspend (but allow local work to resume), pause (without interrupting), and unpause (continue)

=====Suspend your VMs======

cd “C:\Program Files (x86)\VMware\VMware Workstation”

$RunningVMs = .\vmrun list | select-object -skip 1

Foreach ($RunningVM in $RunningVMs)
“Suspending $RunningVM…”
.\vmrun suspend “$RunningVM”


====Resume your VMs ====

cd “C:\Program Files (x86)\VMware\VMware Workstation”

$SuspendedVMs = gci -Include *.vmx -Recurse -Path C:\VMs

Foreach ($SuspendedVM in $SuspendedVMs)
.\vmrun start “$SuspendedVM”

Apr 28, 2013 - General, Powershell, Scripting    1 Comment

How can I create / name a folder with today’s date?

This is very handy if you are using scripts to generate daily logs and would like to put them in a folder with the current date. You can, of course, tweak the commands to suit your requirements:


for /F “tokens=1-4 delims=/ ” %%A in (‘date /t’) do (
set DateDay=%%A
set DateMonth=%%B
set DateYear=%%C

set CurrentDate=%DateDay%-%DateMonth%-%DateYear%

md %CurrentDate%

This will give you a newly created folder with┬átoday’s┬ádate, in the format of DD-MM-YY

How can I search for all users that have the “Network Policy” set to false using PowerShell ?

If you need to search Active Directory to find users who currently have the “Network Access Permission” set to “Deny Access” on the Dial-in tab of their user account


run this Powershell command:

Get-ADUser -Filter {(mail -like “*”) -and (ObjectClass -eq “user”)} -Properties msNPAllowDialin | Where { $_.msNPAllowDialin -match “False” } | fl Name, msNPAllowDialin

You need to ensure you start Powershell with the AD modules installed.

Related Posts Plugin for WordPress, Blogger...