Category Archives: Scripting

Send notification email from SCCM 2012 Task Sequence

I wanted to be able to send an email from a step in a SCCM 2012 OS Deployment (OSD) task sequence. This was so that I could be notified when the task sequence had completed successfully. The account used to … Continue reading

Rate this:

Posted in sccm, Scripting, Windows | Tagged , , , , , , , , , | Leave a comment

Send Windows Event Logs to SQL Database

I’m currently in the process of planning for an AppLocker rollout to all my PCs (about 7,500 of them) due to an increasing amount of malware. You should probably be doing this too. Anyway, a sensible first step is to … Continue reading

Rate this:

Posted in PowerShell, Scripting, Security, Windows | Tagged , , , , , , , , , , , , , , , , , , , , , , , | 4 Comments

Remove Forefront Client Security by force

I was recently trying to upgrade the Antivirus software on some servers from Forefront Client Security to System Center Endpoint Protection 2012 R2. On most servers it worked fine. However on a few I was unable to remove some of … Continue reading

Rate this:

Posted in Scripting, Security, Windows | Tagged , , , , , , , , , , , , , , , , | 2 Comments

PowerShell: Find MTU

I had some issues caused by MTU recently, and decided to write a script to test for the Maximum Transmission Unit that a network or host could cope with. I originally started off by using the PowerShell Test-Connection cmdlet, but … Continue reading

Rate this:

Posted in Networking, PowerShell, Scripting | Tagged , , , , , , , , | 2 Comments

PowerShell script to get temperature from NetBotz

Wrote this to extract the temperature reading from a few NetBotz devices that I have in my datacentres. Note that the second time I call the function, it is getting the temperature from a second (non-docked) sensor pod attached to … Continue reading

Rate this:

Posted in PowerShell, Scripting | Tagged , , , , , , | Leave a comment

PowerShell: Finding user sessions on RDSH servers

If you’ve been working with Citrix Metaframe/Presentation Server/XenApp and/or Microsoft Terminal Server/Terminal Services/Remote Desktop Session Host for a while you’ll probably be familiar with the command line utility quser (or query user). It returns a tabular output showing details of … Continue reading

Rate this:

Posted in PowerShell, Remote Desktop, Scripting | Tagged , , , , , , , , , | Leave a comment

Missing row when using ExecuteReader to fill a DataTable

I’ve been using the following PowerShell code to retrieve the contents of an SQL Server table and store it in a DataTable for fast local processing: $BuildDBConnection = New-Object -TypeName System.Data.SqlClient.SqlConnection -ArgumentList “Server=RCMSQL01;Database=TSBuild;Integrated Security=SSPI” $BuildDBConnection.Open() # Get Main table $SQLCommand … Continue reading

Rate this:

Posted in PowerShell, Scripting | Tagged , , , , , , , , | Leave a comment

PowerShell: There are null values and then there are SQL null values

I was reading some data out of a SQL Server table, and wanted to do an operation if one of the string values returned, MAC, was either blank or null. I was using the following code: $NewServerName = “SomeServerName” $DBServerName … Continue reading

Rate this:

Posted in PowerShell, Scripting | Tagged , , , , , , , | Leave a comment

Powershell function to pin and unpin from Windows Taskbar

Wrote this to make it easy to add and remove pinned items from the taskbar. Code function Pin-Taskbar([string]$Item = “”,[string]$Action = “”){ if($Item -eq “”){ Write-Error -Message “You need to specify an item” -ErrorAction Stop } if($Action -eq “”){ Write-Error … Continue reading

Rate this:

Posted in Applications, PowerShell, Scripting, Windows | Tagged , , , , , , , | 3 Comments

Get and delete DNS A and PTR records via PowerShell

My Remote Desktop Session Host build process is now pretty slick. I can easily rebuild a lot of RDSH VMs very quickly. The process basically involved powering off the existing VM, deleting both it and its Active Directory account, and … Continue reading

Rate this:

Posted in PowerShell, Scripting, Windows | Tagged , , , , , , , , , , , , | 2 Comments