PoshCode Archive  Artifact [2fe88b686b]

Artifact 2fe88b686b9f7c8a20ca71cd11f2e7055909f681ee5f834b0962f705a3858664:

  • File GET-Remoteapps.ps1 — part of check-in [70efc53d75] at 2018-06-10 13:05:22 on branch trunk — Find an Application on remote list of computers. (user: Sean Kearney size: 1829)

# encoding: ascii
# api: powershell
# title: GET-Remoteapps
# description: Find an Application on remote list of computers.  
# version: 0.1
# type: script
# author: Sean Kearney
# license: CC0
# x-poshcode-id: 2121
# x-archived: 2012-06-15T18:22:47
# x-published: 2012-09-06T12:04:00
#
# Example for Accessing Registry remotely comes from MOW from a blog posting here http://thepowershellguy.com/blogs/posh/archive/2007/06/20/remote-registry-access-and-creating-new-registry-values-with-powershell.aspx
#
# Original posting on how to access a remote Registry from The Powershell Guy
# 
# http://thepowershellguy.com/blogs/posh/archive/2007/06/20/remote-registry-access-and-creating-new-registry-values-with-powershell.aspx
#
# This script will Query the Uninstall Key on a computer specified in $computername and list the applications installed there
# $Branch contains the branch of the registry being accessed
#  '

# format of Computerlist.csv
# Line 1 - NameOfComputer
# Line 2 etcetc etc etc etc An Actual name of a computer

$COMPUTERS=IMPORT-CSV C:\Powershell\Computerlist.csv

FOREACH ($PC in $COMPUTERS) {
$computername=$PC.NameOfComputer

# Branch of the Registry
$Branch='LocalMachine'

# Main Sub Branch you need to open
$SubBranch="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"

$registry=[microsoft.win32.registrykey]::OpenRemoteBaseKey('Localmachine',$computername)
$registrykey=$registry.OpenSubKey($Subbranch)
$SubKeys=$registrykey.GetSubKeyNames()

# Drill through the list of SubKeys and examine the Display name

Foreach ($key in $subkeys)
{
    $exactkey=$key
    $NewSubKey=$SubBranch+"\\"+$exactkey
    $ReadUninstall=$registry.OpenSubKey($NewSubKey)
    $Value=$ReadUninstall.GetValue("DisplayName")
    Write-Host $computername, $Value
 
}