Skip to main content

Posts

Showing posts with the label WebAdministration

Calling PS1 from VBS and gotchas with cmdletbindingattribute() - Part 2

This post is in continuation of my previous post  where things got interesting while trying to execute a PS1 from a VBScript which will start/stop the website. At the end of post there was this interesting case where we tried to stop a website which did not exist ...But we would always get a Return code of 0 ...or Success message. Now that is bad for a Production Script as it should fail if we didn't give the correct website name. So for this post my sample VBScript will remain almost same with only one modification.....on the website name (in Bold Red below): Set  objShell =  CreateObject ( "WScript.Shell" ) strCommand =  "powershell.exe -noprofile -file C:\temp\test2.ps1 -websitename  WebSiteDoesnotExist  -action stop -verbose" strError = objshell.run(strCommand, 1 , True ) If  strError  then                              WScript.Echo  "Failed with Exit Code"  & strError &  "." else     WScript.echo  "S...

Calling PS1 from VBS and Web-Administration without the PowerShell Module - Part1

Calling PS1 from VBS Recently I got this strange request to call PowerShell Script from VBScript... Yeah!! I am serious. Well the scenario is that we have a main VBScript which calls other VBScripts to perform Application Deployments on  Servers. In this main VBScript we want to add the functionality to start/stop websites and webapppools as these need to be stopped while deploying the web apps on the server. So to add this functionality to our VBS we want to use PowerShell Scripts. Learning ( skip these for now will make more sense after reading the post) :   WebAdministration Module doesn't work on a PowerShell Instance spawned by the VB Script. Can't really use Advanced Cmdlet Binding Attributes (next post) This task seemed to be easy enough at first ... Sample VBScript 1 : Set  objShell =  CreateObject ( "WScript.Shell" ) strCommand =  "powershell.exe -noprofile -file C:\temp\tes2t.ps1 -websitename DexTestWebsite  -action stop " s...