Episode 181 – Karl Prosser on Portable PowerShell and v3

My PowerShell for Tivoli Endpoint Manager (http://pstem.codeplex.com) project was featured on a recent episode of the PowerScripting Podcast.

Read more… 243 more words

PowerScripting Podcast

A Podcast about Windows PowerShell.
Listen:

In This Episode

Tonight on the PowerScripting Podcast, we talk to Karl Prosser about Portable PowerShell and PowerShell v3

News

This segment is brought to you by TrainSignal

Get online computer based training for you and your whole staff from TrainSignal. TrainSignal offers more than 80 IT training courses in the areas of Security, Network Administration, Virtualization, PowerShell and more. With 24/7 online access, TrainSignal’s training courses are accessible on almost any device including PC, Mac, iPhone, iPad, Android smartphones, and more.  For more info and a list of courses, visit TrainSignal.com.

View original post 181 more words

PowerShell: Test-Host

       
       .Synopsis
            Test to see if this host is online and accessible.
       
        .Description
            Sends two pings the the hostname, then attempts to access the admin share for this host.
       
        .Parameter HostName
            Hostname or IP address to be tested.
       
        .Parameter skipPingTest
            This will allow you to skip the ping test when validating a host is up.
       
        .Parameter skipShareTest
            This will allow you to skip the share test when validating a host is up.
       
        .Example
            Test-Host DanielPC
            Description
            ———–
            Tests the host with both two pings and an admin share connection test.
           
        .Example
            Test-Host DanielPC -p
            Test-Host DanielPC -skipPingTest
            Description
            ———–
            Tests the host by admin share test and skips the ping test…
       
        .Example
            Test-Host DanielPC -s
            Test-Host DanielPC -skipShareTest
            Description
            ———–
            Tests the host by ping test only and skips the admin share test…
           
        .Example
            "DanielPC " | Test-Host
            Description
            ———–
            Receives input from the pipeline for testing if a host is online or not.
           
        .OUTPUTS
            Boolean
       
        .NOTES
            NAME:       Test-Host
            AUTHOR:     Daniel Moran
            Website:    http://www.moranit.com
            LASTEDIT:   04/18/2011
            #Requires   -Version 2.0
       
        .LINK
            https://danielheth.com/2011/04/18/powershell-test-host/

SQL and PowerShell Connectivity

Do you have a SQL server you want to gain access to from PowerShell?  Well you’re in luck, so did I…

My recent connection to BigFix has prompted me to gain access to the BFEnterprise database… Thus I have come up with the following PowerShell function to gain access to my BigFix Server DB installation:

 

function SQLExecute {
    param (
        [string]$SQLSERVER = “<MySQLServerName>”,
        [string]$Database = “BFEnterprise”,
        [parameter(Mandatory = $true)]
        [string]$cmd
        )
    $con = “server=$SQLSERVER;database=$Database;Integrated Security=sspi”
    $da = new-object System.Data.SqlClient.SqlDataAdapter ($cmd, $con)
    $dt = new-object System.Data.DataTable

    $da.fill($dt) | out-null

    return $dt

}

 

This function will return an object(s) of what you requested. 

For Example:  SQLExecute –cmd “select * from computers”

will select all of the registered computers within your BigFix installation.

Or if you have run the Property Mapper utility the following SQL will return object(s) of your computer ID / Computer Name:

SQLExecute -cmd “select ComputerID, ResultsText as ‘Computer Name’ from QUESTIONRESULTS QR where (QR.SiteID = (select SiteID from PROPERTYIDMAP where propertyname like ‘Computer Name’)) AND (QR.AnalysisID = (select AnalysisID from PROPERTYIDMAP where propertyname like ‘Computer Name’)) AND (QR.PropertyID = (select PropertyID from PROPERTYIDMAP where propertyname like ‘Computer Name’))”

 

More to come… have fun!

Digg This