Tags » PowerShell

Changing to Powershell ISE

I have had a constant problem with AdminScriptEditor.  For whatever reason, it will format certain lines which break up my variables (IE.  $  variable).

In a moment of anger, I decided to start using the Powershell ISE.  63 more words


Cleaning up Management Pack XML after SCSM Authoring Tool

For those of you working with System Center Service Manager (SCSM) and have created or edited forms in the Authoring Tool have probably noticed that Management Pack can easily become a couple of hundred rows! 185 more words


PowerShell to the Rescue

Regarding today’s earlier post A Rant about AppData, Paths, and Modules, I’ve hacked together a solution that seems to work…

First of all, please note that in our solution, we’ve taken all the various config files and combined them into a single… 428 more words


speaking at SQL Saturday Porto

This weekend (18 October 2014) I was extremely lucky to have the opportunity to speak at SQL Saturday in Porto : https://www.sqlsaturday.com/341/eventhome.aspx

I had also the amazing opportunity to do a whole day of pre-conference about the basics of SQL Server Analysis Services. 454 more words


Counting Google Results

In a new role now, and having to do a bit of fairly simple trend analysis – although my scripting skills are a little rusty and it took a while to work out. 669 more words


Send notification to a smartphone (Prowl for iOS or Notify My Android)

function Notify-SmartPhone {
# Function to send notification to "Notify My Android" or "Prowl"
# -Prowl or -Android must be specified

     $Priority = 0,

     $Proxy = "",
     $Android = $false,
     $Prowl = $false
  if ($Android) {
    Write-Verbose "Android"
    $URL = 'http://www.notifymyandroid.com/publicapi/notify'
  if ($Prowl) {
    Write-Verbose "Prowl"
    $URL = 'http://api.prowlapp.com/publicapi/add'

  $Notification = new-object System.Collections.Specialized.NameValueCollection

  foreach ($Key in $Notification) {
    Write-Verbose "$Key = $($Notification[$Key])"
  if ($Proxy -ne "") {
    $WebClient = New-Object Net.Webclient
    $WebProxy  = New-Object Net.WebProxy
    $WebProxy.Address = $Proxy
    $WebClient.Proxy = $WebProxy

  try {
    $Response = $WebClient.UploadValues($URL, $Notification)
  } catch {
    Write-Verbose "POST Failed (this does not have to mean that the notification failed!)"
} 30 more words

Connect to a SQL Server database and run a query

function Open-Database {
  $ConnectionString = 'Server=<hostname>,<portnumber>;Database=<databasename>;Trusted_Connection=True;'
  $Connection = New-Object -TypeName System.Data.SqlClient.SqlConnection
  $Connection.ConnectionString = $ConnectionString
  return $Connection

function Run-Query {
  Param ($DB, $Query)
  Try {
    $Command = $DB.CreateCommand()
    $Command.CommandText = $Query
    $Adapter = New-Object -TypeName System.Data.SqlClient.SqlDataAdapter $Command
    $Dataset = New-Object -TypeName System.Data.DataSet
    $Adapter.Fill($Dataset, "data") | Out-Null
    return $Dataset.Tables["data"]
  } Catch {
    Write-Host -ForegroundColor Red "Error running the following query:`n$($Query)"

$DB = Open-Database
RunQuery -DB $DB -Query "SELECT * FROM <table>"