Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Friday, December 20, 2013

Lightweight monitoring solution with PowerShell

For one of my projects, I needed a simple and lightweight monitoring and testing framework for the public website. As we tweaked SharePoint with some custom redirect functionality to improve SEO, and moved the Google Analytics code from one solution to one other, I wanted to make sure these functionalities still work after each release.
As UI bugs will be noticed directly, those more technical features are hardly noticed directly on failure. So there was the need to script and monitor those features.

As I wanted a simple, free and easy to expand solution (I worked with HostMonitor before, it's easy to write small tests there, but it isn't free), I decided to create my own PowerShell framework. Here it is. It is written for PowerShell 2.0, so webrequests are not executed with Invoke-WebRequest but with the C# System.Net variant.
The script is basically executing tests found in one folder, format the results as HTML and sending it by email with a SMTP server. Things to improve are more test outcomes (now it is Success or Failure, but there might be a yellow inbetween warning or so), or possibly using a tool like Selenium to run tests inside a browser session as well.

Sunday, December 4, 2011

Remove BDC Models in PowerShell

I needed a PowerShell script to enumerate over all the installed BDC Models (and delete them), but couldn't find the example on TechNet or MSDN. After trying some things, I found the following script:


$context = "http://sharepoint.local"
$bdc = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType Catalog -ServiceContext $context
foreach ($model in $bdc.GetModels("*") ) {
    Remove-SPBusinessDataCatalogModel –Identity $model
}

Wednesday, March 26, 2008

PowerShell Web UI test automation

Just read an article in MSDN magazine about test automation for Internet Explorer so you can test your web user interface. There are other tools for this (like Selenium), but those need quite a setup.

Execute a search-box test in PowerShell:

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://localhost/Default.aspx")
$ie.visible = $true
$doc = $ie.document
$doc.getElementByID("searchbox").value = "test"
$doc.getElementByID("searchsubmit").click()

Monday, November 12, 2007

PowerShell Shutdown COM+

To shutdown a COM+ object, so you can redeploy the binaries it uses, I had a VBS script to do it. I wondered how I could do it in PowerShell, but lacked time to do so. I just stumbled upon some code to do it, though.

The old script was:

Dim oCatalog ' As COMAdmin.COMAdminCatalog
Dim sName 'As String
Dim sMachine 'As String
Set oCatalog = CreateObject("COMAdmin.COMAdminCatalog")
sName = "Tridion Content Manager"
sMachine = "tridionserver"

oCatalog.Connect sMachine
oCatalog.ShutdownApplication sName



And this became:


$TridionAppName = "Tridion Content Manager"
$TridionMachine = "tridionserver"

$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$comAdmin.Connect($TridionMachine)
$comAdmin.ShutdownApplication($TridionAppName)


(Just leave the line with the call to connect out to run this on your local machine).

Tuesday, January 31, 2006

Monad Dir Highlighting

I'm currently experimenting with the new microsoft shell monad. I always liked the directory en executable highlighting in the linux shell, so I just build a quick script to highlight the directories in an ls query.

$colItems = dir
foreach ($objItem in $colItems)
{
if ($objItem.MshIsContainer )
{ write-host $objItem.Name -foregroundcolor "Blue"}
elseif ( ($objItem.Extension -eq ".exe") -or ($objItem.Extension -eq ".msh") )
{ write-host $objItem.Name -foregroundcolor "Green" }
else
{write-host $objItem.Name}
}

Tuesday, January 17, 2006

Remove Monad for .net 2.0 beta

I installed a beta for monad, the new Microsoft Shell, that needed the asp.net 2.0 beta. But after going live for Visual Studio, I couldn't remove monad, and it didn't run either because the .net beta wasn't available.

How to correct this problem? I figured this out:

So I deleted the Monad folders by hand and all the registry settings, and it worked :D