2011/06/30

Powershell - Launch/Start a process on a remote machine without powershell installed on it

How to launch/start a process on a remote machine when this one does not have Powershell ? ... WMI!

Solution 1 (Ravikanth Chaganti, see his WMI book! Must read!)
$proc = Invoke-WmiMethod `
        -ComputerName Test `
        -Class Win32_Process `
        -Name Create `
        -ArgumentList "Notepad.exe"
Register-WmiEvent `
    -ComputerName test `
    -Query "Select * from Win32_ProcessStopTrace Where ProcessID=$($proc.ProcessId)" `
    -Action { Write-Host "Process ExitCode: $($event.SourceEventArgs.NewEvent.ExitStatus)" }

Solution 2 (The Lonely Administrator)

Function New-RemoteProcess {

2011/06/29

Powershell - Check if all the services with StartMode AUTOMATIC are actually Running

download | new post

Cloning Windows Server 2008 R2 - Use Sysprep (no more NewSID)

Source


Sysprep on Windows Server 2008 R2It is not uncommon for system administrators to clone virtual servers or take an image of physical servers running Windows Server 2008 these days. There are plenty of tools to do that these days (Ghost, Acronis, Platespin for P2V conversions, etc.) If this is something you do regularly then you won’t be unfamiliar with Sysprep or NewSID, but according to Mark Russinovich at Microsoft, the SID doesn’t matter and Sysinternals have now retired NewSID (written by Mark). NewSID isn’t supported in Windows Server 2008 and the only option now is to use Sysprep. Whilst the facts presented on Mark’s blog are correct, I have personally seen many issues cloning or imaging Windows Server 2008 machines that haven’t been cloned with Sysprep first. Let me present a typical scenario that would cause problems here.

2011/06/25

Powershell - Exchange Environment Report

Exchange Environment Report
A quick post on Exchange fellow Steve Goodman who created a nice PowerShell script which generates a basic HTML report on your Exchange environment. When required, you can also e-mail the report, which is nice if you want to schedule the script to run on a daily basis for example.

The script is provided as-is so you can tailor it to your needs. It’s still work in progress, so if you got any requests just send Steve a message.
You can find the post and script here.

Bill Gates: How a Geek Changed the World [Video]

Bill Gates: How a Geek Changed the World [Video]


Just before he stepped down from Microsoft, BBC2’s “The Money Programme” put together a special on Bill Gates and how he made the company into a money making machine. Those of you who love geek history will definitely enjoy this hour long documentary video.

2011/06/13

Powershell and Windows updates

#
# Functions from http://richardspowershellblog.wordpress.com/
#


# --- GET-UPDATE --- #
function get-update {
    $session = New-Object -ComObject Microsoft.Update.Session
    $searcher = $session.CreateUpdateSearcher()
    $result = $searcher.Search("IsInstalled=0 and Type='Software'" )

    $result.Updates | select Title, IsHidden
}

# --- GET-UPDATE --- # (updated)
function get-update2 {
    [CmdletBinding()] 
    param ( 
         [switch]$hidden 
    ) 
    PROCESS{
        $session = New-Object -ComObject Microsoft.Update.Session
        $searcher = $session.CreateUpdateSearcher()

        # 0 = false & 1 = true
        if ($hidden){
             $result = $searcher.Search("IsInstalled=0 and Type='Software' and ISHidden=1" )
        }
        else {
             $result = $searcher.Search("IsInstalled=0 and Type='Software' and ISHidden=0" )
        }

        if ($result.Updates.Count -gt 0){
             $result.Updates | 
             select Title, IsHidden, IsDownloaded, IsMandatory, 
             IsUninstallable, RebootRequired, Description
        }
        else {
             Write-Host " No updates available"
        } 

    }#process

<# 
.SYNOPSIS Discovers available updates 
.DESCRIPTION Interrogates Windows updates for available software updates only. Optional parameter to display hidden updates 
.PARAMETER hidden A switch to display the hidden updates 
.EXAMPLE get-update Displays non-hidden updates 
.EXAMPLE get-update -hidden Displays hidden updates #>
}



# --- GET-INSTALLEDUPDATE --- #
function get-installedupdate {
    $session = New-Object -ComObject Microsoft.Update.Session
    $searcher = $session.CreateUpdateSearcher()
    $result = $searcher.Search("IsInstalled=1 and Type='Software'" )

    $result.Updates | select Title, LastDeploymentChangeTime
}


# --- INSTALL-UPDATE --- #
function install-update {
    $session = New-Object -ComObject Microsoft.Update.Session
    $searcher = $session.CreateUpdateSearcher()

    $result = $searcher.Search("IsInstalled=0 and Type='Software' and ISHidden=0")
    
    if ($result.Updates.Count -eq 0) {
         Write-Host "No updates to install"
    }
    else {
        $result.Updates | select Title
    }

    $downloads = New-Object -ComObject Microsoft.Update.UpdateColl

    foreach ($update in $result.Updates){
         $downloads.Add($update)
    }
     
    $downloader = $session.CreateUpdateDownLoader()
    $downloader.Updates = $downloads
    $downloader.Download()

    $installs = New-Object -ComObject Microsoft.Update.UpdateColl
    foreach ($update in $result.Updates){
         if ($update.IsDownloaded){
               $installs.Add($update)
         }
    }

    $installer = $session.CreateUpdateInstaller()
    $installer.Updates = $installs
    $installresult = $installer.Install()
    $installresult

}

2011/05/31

LazyWinAdmin 0.2

New version of LazyWinAdmin 0.2 (see the download section)

Download now

requires:
-PowerShell 2.0 on local machine
-Permissions on remote machines



Tool - mRemoteNG 1.67 RC3

New version of one of my favorite Admin tool: mRemoteNG



 Download it now!

Changes from 1.67 RC2 to 1.67 RC3
  • Added confirmation before closing connection tabs.
  • Fixed bug 42 - Maximized location not remembered with multiple monitors.
  • Improved loading and saving of window location.
  • Removed flickering on start up.
  • Fixed bug 43 - Creating a duplicate connection causes connection list to no longer be sorted ascending.
  • Improvements to German translation.
Changes from 1.67 RC1 to 1.67 RC2
  • Added partial French translation to the application.
  • Addded Thai translation to the installer.
  • Updated graphics in the installer to mRemoteNG logo.
  • Added buttons for Add Connection, Add Folder, and Sort Ascending (A-Z) to the Connections panel toolbar.
  • Fixed rename edit control staying open when collapsing all folders.
  • Changed sorting to sort all subfolders below the selected folder.
  • Allow sorting of connections if a connection entry is selected.
  • Fixed adding a connection entry if nothing is selected in the tree.
  • Added 15-bit Color RDP setting.
  • Fixed loading of RDP Colors setting from SQL.
  • Added Font Smoothing and Desktop Composition RDP settings.
  • Improved error handling when loading XML connection files.
  • Added the mRemoteNG icon to the list of selectable icons for connection entries.
Changes from 1.66 to 1.67 RC1
  • Fixed migration of external tools configuration and panel layout from Local to Roaming folder.
  • Disable ICA Hotkeys for Citrix connections. Fixes issue with international users.
  • Added a language selection option so users can override the language if they don't want it automatically detected.
  • Fixed RD Gateway default properties and RDP reconnection count setting not being saved.
  • Fixed bug 33 - IPv6 doesn't work in quick Connect box.
  • Moved the items under Tools in the Connections panel context menu up to the top level.