News: Sensation!!! Buying viagra online Hydrocodone ap ap Xanax and drug testing Buying vicodin online Santa claus viagra jokes Oxyphenbutazone Phentermine delivered overnight Cheap viagra Fluoxetine Viagra versand Cheapest viagra in uk Vicodin online pharmacy Lowest price phentermine Us phentermine Phentermine caffeine Lescol Buy meridia online What does generic xanax look like Selegiline Mephentermine Xanax and pregnancy Phentermine online ordering Xanax addiction treatment Amaryl How long does xanax stay in your system Buy cheap no phentermine prescription Adipex Elidel Tramadol online cheap Amprenavir Phentermine Generic meridia Buy viagra without prescription Encare Hydrocodone query Xanax photos Amoxicillin Remeron Nasonex Buy cod phentermine Xanax in pregnancy Buy Zovirax Woman take viagra Ampicillin Purchase cialis Side effect of viagra Viagra lawsuits Buy Norco Phentermine depression What does phentermine look like Effects of phentermine Allopurinol Isotretinoin Soma cube Lisinopril with viagra Picture viagra pill Hydrocodone drug Blue 30 mg 90 free shipping phentermine pharmacy Benicar Strattera Cheapest price phentermine online pharmacy Omnicef Famotidine Cialis injury lawyer ohio Luxury hotel rome xanax description Viagra high blood pressure Valium vs xanax Fioricet medication Labetalol Granisetron Pharmacy phentermine affiliate Hydrocodone overdose Buy Lorazepam Grapefruit viagra Effects of long term xanax use Phentermine on line Diet information phentermine pill Phentermine pictures Tramadol used for Hydrocodone on line Restoril Buy cheap domain online outdoors com xanax Price for generic viagra Buy online viagra Online pharmacies with doctor consultation for viagra Tramadol information Cardizem Viagra online store Mixing viagra and cialis Phenyltoloxamine Xanax withdrawal muscle joint nerve pain Diet hcl phentermine pill 50 mg viagra Tetanus Pravachol Generic viagra lowest prices Phentermine florida Cialis online sales Can woman take cialis Primaquine Ribavirin Canada generic viagra Buy cialis in the uk Phentermine to buy Diamox Pharmacies ship phentermine c.o.d method Cordarone Phentermine cheapest Soma gallery Buy viagra in uk Maker of viagra Doxepin Hydrocodone bitartrate Oxprenolol Clopidogrel Vitamin b12 1000 mcg phentermine and panic attacks Xanax no prescription Alendronate Kanamycin Alphaprodine Low price phentermine Phentermine tablets Lowest price tramadol Thiopropazate Hydrocodone cod Order tramadol online Viagra paypal france How to stop taking xanax Daunorubicin Mixing cocaine and viagra Trimethaphan Flonase Phenylpropanolamine Phentermine us Cheapest phentermine diet pill Vancomycin Natural viagra Adipex p phentermine vs Tramadol online pharmacy Compare viagra cialis levivia Phentermine by cod Cyclopenthiazide Fluphenazine Pyridium Terfenadine Effects viagra Viagra price list Lopressor Fast delivery phentermine Cheap diet phentermine pill Cheapest phentermine pills Quinine Tramadol hcl Fluoxetine Cialis dosages Butorphanol Cheapest viagra price Phentermine without doctor's approval Erectile dysfunction viagra Xanax drug interactions Penbutolol Generic name online qoclick tramadol Glyburide Hydrocodone cough syrup Concerta Fluorescein Methyclothiazide Encainide Buy fioricet Phentermine insulin Phentermine overnight delivery Amantadine Buy phentermine mastercard Buy viagra now online Long term effects of phentermine use Yasmin Canadian viagra Cod phentermine shipped Fluticasone Phentermine buy online Viagra sales online Fosamax Polythiazide Ranitidine Metyrosine Generic viagra overnight Westword fioricet phentermine Phentermine risks Phentermine cash on delivery Adipex diet phentermine pill prescription Ordering xanax online Zetia Adapalene Buy Acyclovir Clomipramine Custom hrt phentermine Phentermine buy cheap Cialis immunity Provigil Xanax manufacturer Viagra cream Urine drug testing of tramadol Imitrex Lopressor Fluticasone Buy Tylenol Female uk viagra Generic cialis Vicodin Phentermine order Marijuana Phentermine us pharmacy online consultation Compare phentermine price Lamisil Ritalin Canadian cialis Methoxsalen Zyrtec Viagra generic drug Phentermine and sibutramine be combined Guanfacine Drug information on xanax Discount meridia Mylan xanax Viagra online pharmacy Diet pill phentermine Diazepam Ambien overdose Viagra herbal alternative Buy Hydrocodone Nicorette Mifepristone Dilantin Glycopyrrolate Colchicine Nortriptyline Lamotrigine Ultram Naprosyn Order fioricet online Plendil Xenical Xanax sexual side effects Smoking xanax Cholestyramine Actos Leucovorin Mesoridazine Phentermine and topiramate for weightloss Dexbrompheniramine Isoxsuprine Sulindac Phendimetrazine versus phentermine Perscription cialis Relafen Glucophage Methdilazine Cheap phentermine canada Herbal viagra for women Fenoldopam Hydrocodone apap Levivia viagra Phentermine studies Plavix Mebanazine Generic sample viagra Ambien side effects Uk online pharmacy phentermine Viagra pharmacy Tricor Tramadol online Buy online prescription viagra Buy viagra pill online Herbal viagra alternative Get viagra drug online Thyroid Cialis dosage Thioridazine Allopurinol Adipex phentermine weight loss Antazoline Viagra prescriptions online Cheapest phentermine 90 day order Phentermine a159 Xanax long term use Meridia vs. Phentermine Purchase viagra Get viagra online Cialis levitra viagra compare Sophia viagra Cod tramadol money orders Pulmonary hypertension viagra Amlodipine Voltaren Isometheptene Pfizer viagra online Cheapest phentermine 90 day orders Phentermine free delivery Which is better cialis or levitra Exelon Inject xanax Cheap diet online phentermine pill Herbal phentermine side effects Methylphenidate Canada cialis generic Cialis experience Does it viagra work Buy phentermine online About xanax Adalat Xanax drug information Mexican pharmacy viagra Climara Viagra substitutes Phentermine raleigh Buy phentermine with no prescription Tramadol withdrawal symptoms Meclofenamate Keyword prescription qoclick tramadol without Diet pill xanax Tramadol and drug tests Viagra women Buy Meridia Phentermine saturday delivery Phentermine directly and discreetly adipex No perscription xanax Medication drug mylan online search phentermine diet Irbesartan Where to buy viagra on line Xanax and valium Xanax half life Vicodin dosage Fill online prescription viagra Tramadol overdose Lexapro Buy cialis without prescription Phentermine withdrawal symptoms Lowest price phentermine with free shipping Cheapest phentermine online Medrol Calan Lodine Phentermine shipped to florida Xenical hgh phentermine quit smoking Ibuprofen Imipramine Order phentermine diet pill Levivia viagra compared Order hydrocodone online Phentermine fastin Lowest prices on phentermine Phentermine interactions Tramadol hcl acetaminotran par Xanax doses Xanax for dogs Viagrarecords Phentermine np Triazolam Cod delivered phentermine Paroxetine 37.5mg phentermine Cetirizine Cialis compare levivia viagra Hydrocodone m367 92 accepted cod phentermine Ethambutol Phentermine no prescription required Phentermine no credit card required Levivia vs cialis vs viagra Buy phentermine prozac Generic viagra canada Adipex diet phentermine pill Buying viagra on line Pill price viagra Buy phentermine saturday delivery ohio Mexican pharmacy phentermine Luvox Xanax online without a prescription Benzthiazide Phentermine at cost with no prescription Crohns phentermine Phentermine blue capules Zithromax Methyldopa Fioricet Doxylamine Viagra online canada Viagra results Phentermine side effects danger Klonopin vs xanax dosage Motrin Avelox Nasonex Pediacare Mirtazapine Cialis generic viagra Free pack sample viagra Rated online pharmacies for phentermine Drug interaction sibutramine and phentermine Phentermine and atkins diet Maxzide Buying vicodin Herbal viagra alternative review Buy cod pay phentermine Buy Xanax Alternative herbal viagra Aminopterin Pancuronium Viagra cialis levitra comparison Vitamin Order generic viagra Ionamin phentermine yellow Didrex Cialis versus viagra Abbr href rel title title viagra Addicted to xanax Phenelzine Buy discount phentermine Buy prescription tramadol without Viagra experience Diatrizoate Buy viagra cheap Does viagra work for women Ambien dosage Phentermine online 100 mg tramadol Ultracet Buy vicodin without prescription Vicodin and alcohol Buy Prozac Ambien prescription Hydrocodone side effects vicodin Phentermine no prescription required next day delivery Xanax dosage Non perscription generic cialis Buy phentermine without prescription Generic soma Xanax online pharmacy no prescription Buy Phentermine Appetite suppressants and phentermine Aricept Phentermine diet pills diet pills Chloroquine Lozol Phentermine online cod Cheapest phentermine online free shipping Xanax ambien Buspirone Lomotil Podophyllum Doxorubicin Hydralazine Buy cheap phentermine yellow Dofetilide Generic cialis from india Free viagra sample Minoxidil Best generic viagra Avandamet Eprosartan Atorvastatin Lindane Vicodin drug test Tramadol side effects Hydrocodone drug test Succinylcholine Fluconazole Free cialis Carphenazine Buy hydrocodone where Discount priced viagra Generic viagra uk Metaraminol Viagra alternative herbal supplement Phentermine yellow Viagra free pill Buy cheap uk viagra Ganciclovir Cheap online order viagra Viagra sales uk Dimenhydrinate Phentermine prescription online Inexpensive viagra Pepcid Per day buy phentermine Prazosin Viagra overdose Actonel Minocin Buy Atarax Xanax pictures Does phentermine really work Pantoprazole Ambien coupon cr Glucophage Buying viagra online uk Spectinomycin Ecstasy Fioricet information Between difference levivia viagra How fast does phentermine work Buy cod online phentermine Buy in online uk viagra Viagra generico impotencia Diflunisal Viagra treatment migraine headache Buy viagra online get prescription Phentermine canada Picture of soma Sell viagra online Cialis comparison levitra viagra Somatostatin Prozac and xanax induced mood disorder Phenazocine Viagra advertisement Cyproheptadine Cheap viagra generic What happens when women take viagra Trihexyphenidyl Beclomethasone Discount phentermine to florida Phentermine pill town Ultram tramadol hci tablet Xanax xr Buy levivia viagra Alfentanil Viagra for woman information Safe internet shopping generic viagraeng Streptomycin Diet pills phentermine Belladonna Taking phentermine Nexium Avalide Hytrin Clonazepam Fioricet description Tramadol cod Generic xanax 2mg Meridia weight loss Compare levivia viagra Buy phentermine tablet 2005 comment december leave viagra Viagra price comparison Xanax addiction Phentermine on line w&o prescription Lexapro Info on meridia Vicodin cod Phentermine works Online phentermine prescription Nystatin Adipex phentermine pill Avodart Phentermine overnight Dobutamine Best price for generic viagra Phenytoin Soma financial Esomeprazole Lexapro and xanax Xanax without a prescription Cheep phentermine Generic viagra cialis Bromocriptine Simethicone Cafergot Cheap phentermine prescription Best price for viagra in the uk Viagrafix corporation Cefadroxil Minipress Edrophonium Chinese viagra dragon power Digoxin Acetazolamide Tramadol prescriptions Trimethobenzamide Simvastatin Pentoxifylline Femara Viagra mexico Mixing viagra and cialis Codeine Viagra cialis generic Xanax gg 258 Triprolidine Buy soma Buy cialis online Viagra jokes Soma Glyburide Xanax detox Xanax Mobic Buy generic phentermine Buy discount cialis Free viagra without prescription Hydrocodone guaifenesin Chlorambucil Xanax paypal Bromodiphenhydramine Olanzapine Atacand Hexoprenaline Xanax online overnight Bricanyl Diprolene Estrogen Enalapril Tramadol cause kidney problems Generic viagra cheap Phentermine and glucophage Methotrexate Brand drug generic name viagra Viagra dose Viagra on line Cialis side effects Phentermine 37.5 mg no prescription Buy online securely viagra Hydrocodone bitartrate acetaminophen Viagra useage Cheaper viagra levivia cyalis Soma restaurant Ativan Hydrocodone overnight Online pharmacy prescription viagra Phentermine prescribed online Methenamine Tramadol 50mg Clozapine Topamax Purchase viagra on line Generic cialis india Reglan Can woman take viagra Generic cialis overnight Chlorhexidine Order phentermine cod online Estrone Cardura From generic india viagra Oxymetazoline Hydrocodone information Order phentermine online without perscription Cialis vs viagra Arthrotec Meridia Ceftin Adipex loss phentermine weight Chantix Bactrim Xanax zoloft Naloxone Phentermine for sale Buy Xenical Electricity Free viagra sample before buying Cheap online phentermine prescription Discount phentermine Viagra uk sales Buy lvivhostcom online viagra viagra Comparison levivia viagra Phentermine faqs Eon phentermine Pentasa Soma sleep Buy xanax without a prescription Pyridostigmine Phentermine sales Carbarsone Dalteparin Deslanoside Paromomycin Lawsuits involving blindness caused by viagra Dexfenfluramine Ephedrine Cefuroxime Phentermine resin Order phentermine c o d Research phentermine tolerance Order phentermine by cod Drug laws ohio diet phentermine Buy generic viagra online Fioricet phentermine shipping Alternatives to viagra Cheapest xanax online Phentermine online diet pill Buy cheap domain onlinemiheyorg phentermine phentermine Anafranil Cheapest phentermine diet pills Premarin Phentermine no credit card cod Phentermine success stories Buy phentermine online with pay pal Xanax for sale Free overnight phentermine shipping Alprazolam xanax over night Women using viagra Butriptyline Buy xanax online without a prescription Montelukast Online consultations and prescriptions phentermine Atorvastatin Natural viagra alternative Phentermine 37 5 Best price phentermine Adipex phentermine prescription Tramadol hc Tramadol dosage Catapres Estradiol Liquid cialis Xanax drug prescription Tramadol hci Phentermine low prices Celexa Nystatin Acitretin Phentermine diet pills cheap Viagra tablet Ergocalciferol Buspirone Mecamylamine Appetite suppressants equivelant to phentermine Podofilox Viagra cream for woman Bontril Female spray viagra Natural over counter just like viagra stores Phenergan Bosch power tools zio lowest viagra History of phentermine use Pictures of mylan xanax Perscription phentermine Azithromycin Xanax dosing Phentermine ups shipped Phentermine prescriptions online Buy discount viagra online Carbenicillin Order generic cialis Xanax in urine Norflex Pentaerythritol Xanax abuse Phentermine delivered cod Online pharmacy and phentermine overnight Thiamine


Archive for Scripting

SCVMM: Creating Checkpoints with PowerShell

Posted in Scripting, PowerShell, SCVMM by Ben Christian on March 19th, 2007

It isn’t possible to create a checkpoint with SCVMM beta1 for VMs that are running. The obvious solution is to write a script to stop the VM first, then create the checkpoint and start it again. I’ve written a script that does exactly that, and it does it for all running VMs.

When I first looked at the checkpoint feature I was dissapointed that there wasn’t an option to add a description. I’ve discovered that while it’s not possible to add and view descritptions through the GUI, you are able to do it using PowerShell.

The following script stops all running VMs, creates a checkpoint with a description, then starts the VMs again.

$VMs = Get-VM -server localhost | where{$_.VMState -eq 'Running'}
$StopVMs = $VMs | Stop-VM
$CheckpointResult = $VMs | New-VMCheckPoint -description "CheckPoint created from script"
$StartVMs = $VMs | Start-VM

You won’t be able to view the description through the GUI, but you can see it if you retreive the checkpoint information via the Get-VMCheckpoint cmdlet:

Get-vmcheckpoint -server server1

Note that server1 is the SCVMM server, not a VM. The cmdlet will list all checkpoints for all VMs that are managed by SCVMM. There is a -VM option, but it doesn’t work with beta1 (along with a lot of other options) There is a way to get around this limiation however, and that is to get the VM object first and then use the Get-VMCheckPoint cmdlet. You can do this for other commands like Start-VM and Stop-VM as well. Here’s an example, including the output:

PS C:\> $VM = "wnlabap101"
PS C:\> $VMObject = Get-VM -server localhost | where{$_.Name -eq $VM}
PS C:\> $VMObject | Get-VMCheckPoint -server localhost

VM : WNLABAP101
ObjectType : VMCheckpoint
Accessibility : Public
Name :
Description :
CreationTime : 8/03/2007 10:13:35 AM
ModifiedTime : 8/03/2007 10:13:38 AM
AccessedTime : 8/03/2007 10:13:38 AM
MarkedForDeletion : False
MostRecentTask :
ServerConnection : Microsoft.VirtualManager.Monad.Remoting.ServerConnection
ID : ca85e266-e658-47d5-951a-42af29762e8d

VM : WNLABAP101
ObjectType : VMCheckpoint
Accessibility : Public
Name :
Description : CheckPoint created from script
CreationTime : 19/03/2007 4:28:53 PM
ModifiedTime : 19/03/2007 4:28:56 PM
AccessedTime : 19/03/2007 4:28:56 PM
MarkedForDeletion : False
MostRecentTask :
ServerConnection : Microsoft.VirtualManager.Monad.Remoting.ServerConnection
ID : 1533e5df-f86c-4366-bedf-56e5944a8a83

VM : WNLABAP101
ObjectType : VMCheckpoint
Accessibility : Public
Name :
Description :
CreationTime : 12/03/2007 1:25:08 PM
ModifiedTime : 12/03/2007 1:25:11 PM
AccessedTime : 12/03/2007 1:25:11 PM
MarkedForDeletion : False
MostRecentTask :
ServerConnection : Microsoft.VirtualManager.Monad.Remoting.ServerConnection
ID : 899be449-6130-41ba-bbe9-ba47ae907981

SCVMM: Starting VMs with PowerShell

Posted in Scripting, PowerShell, SCVMM by Ben Christian on March 19th, 2007

Well I promised that I’d post again soon, and I think 2.5 hours later fullfills that promise! Now that I have the basics down, I looked at creating the most obvious script - “Start all VMs that are stopped”. I did a lot of googling and couldn’t find any examples, so I worked it out myself - not that it is very complex at all. Here are the 2 lines of code that will start all stopped VMs:

$StoppedVMs = Get-VM -server localhost | where{$_.VMState -eq 'PowerOff'}
$StartResult = $StoppedVMs | Start-VM

It’s very straight forward; the first line creates a collection of VMs that are stopped. The second line starts each VM based on that collection. I used $StartResult simply to suppress the output created by the Start-VM cmdlet. The next script that I am planning to create will stop a VM, create a checkpoint and then start it again.

SCVMM Powershell basics

Posted in Scripting, PowerShell, SCVMM by Ben Christian on March 19th, 2007

When I first fired up Powershell I was searching for the SCVMM related cmdlets but couldn’t see them. I ran Get-Command to list all the cmdlets but I didn’t see any related to VMs. I saw a reference to a Get-VM command after doing some googling, but when I tried to run the command it failed with:

PS C:\> get-vm
'get-vm' is not recognized as a cmdlet, function, operable program, or script file.
At line:1 char:6
+ get-vm <<<<

This was becuase I had started powershell using the shortcut from the PowerShell 1.0 start menu folder and not the shortcut from the Microsoft System Center Virtual Machine Manager 2007 start menu folder.

If you take a look at the shortcut’s target, you can see that it is starting powershell with the -PSConsoleFile switch:

"C:\Program Files\Windows PowerShell\v1.0\powershell.exe" -PSConsoleFile "D:\Program Files\Microsoft Systems Center Virtual Machine Manager 2007\bin\cli.psc1" -NoExit

So it appears that the SCVMM cmdlets are loaded from the cli.psc1 file that is included in the shortcut target, and that would explain why my first attempt at executing Get-VM didn’t work.

Once I started using the correct shortcut I started to explore all of the SCVMM related cmdlets. Get-Command is a good way to do this. You can also use Get-Command *vm to list all of the commands that end in “vm”. This however won’t list all of the commands related to SCVMM as not all of them are associated with VM functions. For example there are also cmdlets associated with Virtual Hard Disks.

I’ve listed all of the SCVMM cmdlets below. To generate this list I used Get-Command | CLIP which outputted all of the cmdlets to the clipboard. I then pasted the restults in notepad and removed all of the non-SCVMM commands by comparing them against the same results that I generated from the standard powershell console (by using the standard shortcut).

Add-VFD
Add-VirtualDisk
add-vmhost
add-vmhostnetworkadapter
Copy-HardDisk
discardsavedstate-vm
discover-vmhost
Get-DVDDrive
Get-FloppyDrive
Get-HardwareConfig
Get-ISO
Get-LibraryServer
Get-MachineConfig
Get-NetworkAdapter
Get-OperatingSystem
Get-OSConfig
Get-Script
Get-SelfServicePolicy
get-step
get-task
Get-Template
Get-VFD
Get-VirtualDisk
get-virtualnetwork
Get-VM
Get-vmcheckpoint
get-vmhost
Get-VMHostGroup
get-vmhostnetworkadapter
Get-VMHostRating
get-vmhostvolume
Move-VM
Move-VMHost
Move-VMHostGroup
New-DVDDrive
New-HardwareConfig
New-MachineConfig
New-NetworkAdapter
new-OSConfig
new-p2v
New-patchcache
New-SelfServicePolicy
New-Template
new-virtualnetwork
New-VM
New-vmcheckpoint
New-VMHostGroup
refresh-vm
refresh-vmhost
Remove-DVDDrive
Remove-HardwareConfig
Remove-ISO
Remove-NetworkAdapter
Remove-OSConfig
Remove-Script
Remove-SelfServicePolicy
Remove-Template
Remove-VFD
Remove-VirtualDisk
remove-virtualnetwork
Remove-VM
Remove-vmcheckpoint
remove-vmhost
Remove-VMHostGroup
remove-vmhostnetworkadapter
restart-task
restart-vm
Restore-vmcheckpoint
resume-vm
savestate-vm
Set-DVDDrive
Set-FloppyDrive
Set-HardwareConfig
Set-ISO
Set-NetworkAdapter
set-OSConfig
Set-Script
Set-SelfServicePolicy
set-server
Set-Template
Set-VFD
Set-VirtualDisk
set-virtualnetwork
Set-VM
set-vmhost
Set-VMHostGroup
shutdown-vm
start-vm
stop-task
stop-vm
Store-VM
suspend-vm

Normally, if you want to learn more about a command, you can use get-help and specify the command. However if I use Get-Help Get-VM I get an error:

PS C:\> get-help get-vm
Get-Help : Error loading help content for Get-VM from file "Monad.ImgLibCmdlet.
dll-Help.xml". Details: Monad.ImgLibCmdlet.dll-Help.xml.
At line:1 char:9
+ get-help <<<< get-vm

I beleive this is because the help file for the command hasn’t been written yet (it is only Beta1 after all!). This is consistent with the fact that the help file for the SCVMM console is mostly empty too. I discovered another way to find out more information about each command. Using Get-Command lists a ‘Definition’ column, but most of the text is truncated. However, if you use the Format-List option it will output all of the text:

PS C:\> get-command get-vm | format-list

Name : Get-VM
CommandType : Cmdlet
Definition : Get-VM -Server [-Verbose] [-Debug] [-Erro
rAction ] [-ErrorVariable ] [-OutV
ariable ] [-OutBuffer ]

Path :
AssemblyInfo :
DLL : D:\Program Files\Microsoft Systems Center Virtual Machine Ma
nager 2007\bin\Monad.ImgLibCmdlet.dll
HelpFile : Monad.ImgLibCmdlet.dll-Help.xml
ParameterSets : {__AllParameterSets}
ImplementingType : Microsoft.VirtualManager.Monad.Cmdlets.GetVMCmdlet
Verb : Get
Noun : VM

This helped me get a bit further with scripting SCVMM, becuase some of the cmdlets prompt for values unless you specify them. For example, if you use Get-VM it will prompt for a server value:

PS C:\> get-vm

cmdlet get-vm at command pipeline position 1
Supply values for the following parameters:
Server:

The server value required is the name of the SCVMM server. You can pipe the name by issuing the command with the -server option, e.g get-vm -server "labscvmm01". This will allow you to actually use the command in a script.

That’s all I’ll cover in this post, but I have more to add so watch this space!

Getting Started with PowerShell

Posted in Scripting, PowerShell by Ben Christian on March 16th, 2007

I’m currently setting up a Microsoft System Center Virtual Machine Manager (SCVMM) environment. I can see that there are quite a few things that I’d like to script (starting and stopping VMs, creating checkpoints etc) so it’s time to start playing around with PowerShell.

One of the first things that I noticed was that I wasn’t able to run .ps1 scripts due to the execution policy. By default, only interactive commands can be run in PowerShell; all scripted commands are restricted. You can however change this to one of these settings:

Restricted
- Default execution policy.
- Does not run scripts.
- Interactive only.

AllSigned
- Runs scripts.
- All must be signed by a publisher that you trust.

RemoteSigned
- Runs scripts.
- Downloaded files must be signed by a publisher that you trust.

Unrestricted
- Runs scripts.
- No digital signature is required.

(note that I pasted the settings from the help text that generated by running Get-Help Set-ExecutionPolicy)

To get started, I set it to RemoteSigned by running the following command:

set-executionpolicy RemoteSigned

Once I set the execution policy I was able to run .ps1 files. To run a .ps1 file, open notepad and paste in a powershell command, for example write-host "test", then save the file with a .ps1 extention, for example test.ps1. To run the script, open PowerShell and type in the full path name of the file. Note that you can ommit the extension:

PS C:\> c:\scripts\test
test

If you are already in the correct directory (which you can change by using cd\ c:\scripts then you can just issue .\test:

PS C:\Scripts> .\test
test

So that’s it. I’ll post some more examples specific to SCVMM once I’ve got some scripts working.

New Script Added - Remove a list of users from all of their groups

Posted in Scripting, Active Directory, Exchange 2003 by Ben Christian on August 27th, 2006

We recently had hundreds of users leave our organization due to a takeover and we needed to remove each user from all of their distribution lists and security groups. Although we wanted to remove the users from all groups, I wanted to ensure that we had a record of what groups they were members of in case we needed to add them back in. The script that I created removes the user from all of their groups, but first records the list of groups they are member of and exports the list into a report file. We’ve already had two cases where we disabled a user and removed them from all groups and was later informed that the user’s termination date had been moved forward so their account needed to be reinstated. The user’s previous group membership listed in the report file made it very easy for us to add them back into the groups that they should belong to while they are still with the company.

I’ve added the script here.

New Exchange scripts added to the scripts page

Posted in Scripting, Messaging, Active Directory, Exchange 2003 by Ben Christian on June 22nd, 2006

I’ve added 2 scripts that I created recently to the scripts page. Check out the links below.

VBScript - Export a list of Mail Enabled Public Folders visible in the GAL
VBScript - Export a list of all Mailboxes with their home Server, Storage Group and Database.

Added Script: VBScript - Search Outlook Message attachments

Posted in Scripting, Outlook, Messaging by Ben Christian on March 30th, 2006

I have added a script that I created last week to search for text in Outlook message attachments.

VBScript - Search Outlook Message attachments

Locking down the Windows Scripting Host with Software Restriction Policy

Posted in Windows Desktop, Security, Scripting, Active Directory by Ben Christian on March 1st, 2006

The windows scripting host (WSH) allows administrators to execute scripts to automate administrative tasks, execute network login scripts and query systems for information - just to name just a few of it’s benefits.  I regularly write and run scripts; in fact I sometimes wonder how I got by before I ventured into the scripting realm.  The problem with the windows scripting host however is that it can be a launch-pad for malicious code.  Some administrators choose to disable the use of WSH on workstations and servers to prevent malicious code from executing.  While this makes a lot of sense from a security standpoint, it severely cripples your ability to automate admin tasks, and if you’re using vbscript based login scripts then you’re going to have a real problem. 

A far better approach is to use software restriction policies to dictate which scripts are permitted to run.  Software restriction polices are a new feature available in Windows Server 2003 and Windows XP that are set via Group Policy.  You’ll find the software restriction policy under Computer Configuration/Windows Settings/Security Settings/Software Restriction Policy

Software restriction policies are designed to control the execution of all executables, not just scripts.  There are 4 types of software restriction rules; I’m going to focus on the 3 that are beneficial to locking down the Windows scripting host.  To implement the rules, you simply create them in the Additional Rules folder.  Note that the folder already contains 4 default rules.

SRP rules.JPG

Path Rules:

Perhaps the simplest to implement, path rules let you either allow or disallow executables to run based on the path that they are launched from.  For example, you could disallow the execution of .vbs files (and the various extensions associated with script files) but permit those files that are in particular network share to run.

In this Example, you would create the following rules:

Rule Type
Security Level
Value
Path Disallowed *.vbs
Path Disallowed *.vbe
Path Disallowed *.js
Path Disallowed *.jse
Path Disallowed *.wsf
Path Disallowed *.wsh
Path Unrestricted \\ScriptsServer\Scripts\*.*

You could also use path rules to disallow vbscript files from running but allow them to run from your netlogon shares so that vbscript based login scripts could run:

Rule Type
Security Level
Value
Path Disallowed *.vbs
Path Disallowed *.vbe
Path Disallowed *.js
Path Disallowed *.jse
Path Disallowed *.wsf
Path Disallowed *.wsh
Path Unrestricted %logonserver%\Scripts\*.*

Note that Microsoft’s recommendation is to avoid using environment variables where possible, as environment variables can be changed by the user to point to a different path.  If you choose not to use the %logonserver% environment variable you may want to consider using your domain controllers’ names instead. This may be cumbersome if you have a large number of DCs, but you do have the ability to use wildcards in path rules, so if all of you domain controllers where named DC1 - DC100 you could implement a policy similar to the following:

Rule Type
Security Level
Value
Path Disallowed *.vbs
Path Disallowed *.vbe
Path Disallowed *.js
Path Disallowed *.jse
Path Disallowed *.wsf
Path Disallowed *.wsh
Path Unrestricted \\DC*\Scripts\*.*

I’m comfortable in using the %logonserver% variable, and would be happy to use the first example in a production environment.

Hash Rules:

Hash rules have their advantages, however for locking down WSH they don’t provide too much flexibility.  Using a hash rule, you can allow or disallow the execution of files based on their content.  When you create a hash rule, a “hash” of the file is calculated.  Each time an executable is run, a hash of the file is compared with the hash stored in the policy.  In the case of locking down WSH, you could create a path rule to disallow all vbscript files, and then create a hash rule for each script that you want to allow.  While this may be suitable if you are using a single login script that rarely changes, or if you use only a handful of admin scripts that rarely change, it isn’t ideal for environments where scripts frequently change or like me you write new scripts every week.  The advantage to using hash rules over path rules though is that you can modify the filename and the hash will not change.  You can also run the script from any path;  as long as you don’t change the actual script itself you won’t need to modify the rule.

Example of hash rule to allow approved scripts:

Rule Type
Security Level
Value
Path Disallowed *.vbs
Path Disallowed *.vbe
Path Disallowed *.js
Path Disallowed *.jse
Path Disallowed *.wsf
Path Disallowed *.wsh
Hash Unrestricted SampleScript.vbs

  

Certificate Rules:

Certificate rules are an excellent way to lock down WSH to only allow approved scripts to run.  With a certificate rule, you import a digital certificate into a rule and then digitally sign each script that you want to approve with the same certificate.  The advantage to using certificate rules over path or hash rules is that the contents, path or filename of the script can change without preventing the approved script from running. 

The downside to using certificate rules is that you either need to purchase a digital certificate from a trusted public CA or install your own CA server and issue a certificate from there.  In both cases, the CA needs to be defined in the ‘Trusted Root Certification Authorities’ on your workstations and servers.

Importing the certificate

Once you have obtained a certificate to sign your scripts, you need to import the certificate into the rule.  This is fairly straight forward, you simply create the rule, then browse to the certificate file (*.cer, *.crt).

Signing Scripts

Strangely enough, you actually need to use a script to signs scripts.  The following is an example of a script that signs the C:\Scripts\script.vbs script with a certificate called Ben Christian.  The certificate must first be imported into the certificate store of the machine that you run the script on.

set objSigner = WScript.CreateObject(”Scripting.Signer”)
objSigner.SignFile “C:\Scripts\script.vbs”, “Ben Christian” 

Like the other rules, to implement a certificate rule to allow signed scripts to run, you would first create path rules to prevent the various script extensions from running.

Example of a certificate rule to allow approved scripts:

Rule Type
Security Level
Value
Path Disallowed *.vbs
Path Disallowed *.vbe
Path Disallowed *.js
Path Disallowed *.jse
Path Disallowed *.wsf
Path Disallowed *.wsh
Certificate Unrestricted Certificate used to Sign Scripts

Using Certificate rules is probably the most secure way to lock down WSH with software restriction policy.  If certificate rules seem too cumbersome to implement, path rules are a good way to go.  In any case, implementing software restriction policies to lock down WSH on your client and server machines is better than doing nothing, and is an ideal balance between security and convenience.

New script added to Scripts page - Force AD Replication

Posted in Scripting, Active Directory by Ben Christian on February 16th, 2006

I created a new script today to force AD replication between a number of servers.  I’ve explained how the script works on the script page, check it out if you’re interested.

VBScript - Force AD Replication

Scripts page

Posted in Scripting by Ben Christian on February 13th, 2006

I’ve created a page for script examples and have posted a script there.  I’ll add some more in the near future.

VBScript - Toggle proxy server


« Previous entries