Professional Documents
Culture Documents
@allaboutclait
The Powershell scripts should be saved as .ps1 files and then run using
Powershell ISE. Any one-line scripts can be run from the Powershell
command prompt (best to right-click Powershell and select Run as
administrator). I imported the results using Excels data import facility
ensuring any columns were formatted as text if they were likely to lose
leading zeroes or other information.
Powershell script to find all active directory PCs with OS and service pack
using Quest active directory powershell snap-in (available from Dells
website at http://tinyurl.com/oukq26q tick the box to continue to
download, Im afraid its a bit of a hassle to get hold of otherwise):
Add-PSSnapin Quest.ActiveRoles.ADManagement
Get-QADComputer | Export-Csv -Path C:\pcs.csv
Powershell script to find all installed applications using a source .csv file
containing computers to query (you will need to cross-check the results to
make sure all machines responded):
##################################################
########################
$comments = @'
Author: Kevin Higgins
Date: 1/24/2014
Purpose: Remotely pull a list of all programs installed on a
windows-based computer.
Misc Info: This script is rewritten from the code in the URL below.
Difference include:
6. Skips loop processing if a computer's registry is NOT accessible. (this is the 'trap'.
I got tired of seeing red text due to inaccessible computers.)
Reference
URL: http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/13/use-
powershell-to-quickly-find-installed-software.aspx
If not, the from admin cmd prompt, run these two commands
Prerequisite2: ComputersToCheck.csv
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersio
n\Uninstall
'@
##################################################
########################
clear-host
$array = @()
foreach($pc in $computers) {
#$pc = $computers[0]
$computername = $pc.computername
$UninstallKey32 =
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
$UninstallKey64 =
"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
#Create an instance of the Registry Object and open the HKLM base key
$reg = $null
trap {; Continue};
[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',
$computernameFQDN) | out-null
$reg =
[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',
$computernameFQDN)
#Drill down into the Uninstall key using the OpenSubKey Method
$regkey32 = $null
$regkey64 = $null
$regkey32 = $reg.OpenSubKey($UninstallKey32)
$regkey64 = $reg.OpenSubKey($UninstallKey64)
$subkeys32 = $null
$subkeys64 = $null
$subkeys32 = $regkey32.GetSubKeyNames()
$subkeys64 = $regkey64.GetSubKeyNames()
#32bit Open each Subkey and use GetValue Method to return the
required values for each
foreach($key in $subkeys32){
$thisKey = $UninstallKey32+"\\"+$key
$thisSubKey = $reg.OpenSubKey($thisKey)
$array += $obj
#$array.length
#64bit Open each Subkey and use GetValue Method to return the
required values for each
foreach($key in $subkeys64){
$thisKey = $UninstallKey64+"\\"+$key
$thisSubKey = $reg.OpenSubKey($thisKey)
$array += $obj
}
#$array.length
##################################################
########################
'***************************************************
'This script will pull all users that have Dial-in
'access from Active Directory and the OU the account
'is in and writes the values out to the file RRAS_VPN_Users.txt
'***************************************************
Option Explicit
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Dim objConnection, objCommand, objRootDSE
Dim objRecordSet, ou
Dim namingContext, fso, outFile
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
WScript.Echo "Complete"
WScript.Quit
set cn = createobject("ADODB.Connection")
set cmd = createobject("ADODB.Command")
cn.open "Provider=ADsDSOObject;"
cmd.activeconnection = cn
cmd.commandtext = ldapFilter
set rs = cmd.execute
if rs.eof <> true and rs.bof <> true then
ou = rs(0)
ou = mid(ou,instr(ou,",")+1,len(ou)-instr(ou,","))
getOUByuserName = ou
end if
rs.close
cn.close
end function