![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | New-PS Drive on remote computer Hi, I am using this script to get the list of all softwares installed on a computer. New-PSDrive -Name Uninstall -PSProvider Registry -Root HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall Get-ChildItem -Path Uninstall: | ForEach-Object -Process { $_.GetValue("DisplayName") } | sort-object DisplayName While this works fine for a local computer, how would I extend this script to work on a remote computer and that also in a loop for hundreds of computers. Is it possible to connect to a remote computer and then create the drive, extract the data and then delete the drive and then move on to the next computer. Thanks Terminator. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: New-PS Drive on remote computer You could use the .NET provider: function Get-Apps { Param([string]$server) $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $Server) $regKey = $regKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") $regKey.GetSubKeyNames() # $regKey | gm # uncomment for methods\properties you can use. } Of course you could pretty up the code a bit and get different information, but this is basically it. You could also add begin/process/end to process piped information. function Get-Apps { Param([string]$server) Begin{ function CheckRegKey{ param([string]$srv) $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $Srv) $regKey = $regKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") $regKey.GetSubKeyNames() # $regKey | gm # uncomment for methods\properties you can use. } } Process{ if($_){ CheckRegKey $_ } } End{ if($Server){ CheckRegKey $server } } } p.s. Sorry for the formatting... Blasted News Readers!!! "Terminator" <Terminator@discussions.microsoft.com> wrote in message news:4DAA344B-77BD-4AD8-A4A6-D0E9E2418AAE@microsoft.com... > Hi, > > I am using this script to get the list of all softwares installed on a > computer. > > New-PSDrive -Name Uninstall -PSProvider Registry -Root > HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall > > Get-ChildItem -Path Uninstall: | ForEach-Object -Process { > $_.GetValue("DisplayName") } | sort-object DisplayName > > While this works fine for a local computer, how would I extend this script > to work on a remote computer and that also in a loop for hundreds of > computers. > > Is it possible to connect to a remote computer and then create the drive, > extract the data and then delete the drive and then move on to the next > computer. > > Thanks > > Terminator. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: New-PS Drive on remote computer Hi Brandon, Thanks for the reply. Could you please help on how to invoke this function from a ps1 file. and how would you write all the information to a file for each server that is passed to the function. Thanks Terminator. "Brandon Shell" wrote: > You could use the .NET provider: > > function Get-Apps { > Param([string]$server) > $regKey = > [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, > $Server) > $regKey = > $regKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") > $regKey.GetSubKeyNames() > # $regKey | gm # uncomment for methods\properties you can use. > } > > Of course you could pretty up the code a bit and get different information, > but this is basically it. > You could also add begin/process/end to process piped information. > > function Get-Apps { > Param([string]$server) > Begin{ > function CheckRegKey{ > param([string]$srv) > $regKey = > [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, > $Srv) > $regKey = > $regKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") > $regKey.GetSubKeyNames() > # $regKey | gm # uncomment for methods\properties you can use. > } > } > Process{ > if($_){ > CheckRegKey $_ > } > } > End{ > if($Server){ > CheckRegKey $server > } > } > } > > > p.s. Sorry for the formatting... Blasted News Readers!!! > > "Terminator" <Terminator@discussions.microsoft.com> wrote in message > news:4DAA344B-77BD-4AD8-A4A6-D0E9E2418AAE@microsoft.com... > > Hi, > > > > I am using this script to get the list of all softwares installed on a > > computer. > > > > New-PSDrive -Name Uninstall -PSProvider Registry -Root > > HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall > > > > Get-ChildItem -Path Uninstall: | ForEach-Object -Process { > > $_.GetValue("DisplayName") } | sort-object DisplayName > > > > While this works fine for a local computer, how would I extend this script > > to work on a remote computer and that also in a loop for hundreds of > > computers. > > > > Is it possible to connect to a remote computer and then create the drive, > > extract the data and then delete the drive and then move on to the next > > computer. > > > > Thanks > > > > Terminator. > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: New-PS Drive on remote computer You have two options... 1 - You could copy the function to a text file. Name it anything.ps1. - You can then . source the file (this puts the function in your current context.): PS> . \PathtoScript\anything.ps1 When its in your context you can just call the function directly: PS> Get-Apps ServerName or PS> $slist | Get-Apps 2 - Remove the function Get-Apps { and ending }. - Save the text file as Get-Apps.ps1 PS> PathtoScript\Get-Apps.ps1 ServerName or PS> $slist | PathtoScript\Get-Apps.ps1 -- Brandon Shell http://mybsinfo.blogspot.com/ "Terminator" <Terminator@discussions.microsoft.com> wrote in message news:E2767453-2605-4619-935B-83BFE6A41CA8@microsoft.com... > Hi Brandon, > > Thanks for the reply. Could you please help on how to invoke this function > from a ps1 file. and how would you write all the information to a file for > each server that is passed to the function. > > Thanks > > Terminator. > > "Brandon Shell" wrote: > >> You could use the .NET provider: >> >> function Get-Apps { >> Param([string]$server) >> $regKey = >> [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, >> $Server) >> $regKey = >> $regKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") >> $regKey.GetSubKeyNames() >> # $regKey | gm # uncomment for methods\properties you can use. >> } >> >> Of course you could pretty up the code a bit and get different >> information, >> but this is basically it. >> You could also add begin/process/end to process piped information. >> >> function Get-Apps { >> Param([string]$server) >> Begin{ >> function CheckRegKey{ >> param([string]$srv) >> $regKey = >> [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, >> $Srv) >> $regKey = >> $regKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") >> $regKey.GetSubKeyNames() >> # $regKey | gm # uncomment for methods\properties you can use. >> } >> } >> Process{ >> if($_){ >> CheckRegKey $_ >> } >> } >> End{ >> if($Server){ >> CheckRegKey $server >> } >> } >> } >> >> >> p.s. Sorry for the formatting... Blasted News Readers!!! >> >> "Terminator" <Terminator@discussions.microsoft.com> wrote in message >> news:4DAA344B-77BD-4AD8-A4A6-D0E9E2418AAE@microsoft.com... >> > Hi, >> > >> > I am using this script to get the list of all softwares installed on a >> > computer. >> > >> > New-PSDrive -Name Uninstall -PSProvider Registry -Root >> > HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall >> > >> > Get-ChildItem -Path Uninstall: | ForEach-Object -Process { >> > $_.GetValue("DisplayName") } | sort-object DisplayName >> > >> > While this works fine for a local computer, how would I extend this >> > script >> > to work on a remote computer and that also in a loop for hundreds of >> > computers. >> > >> > Is it possible to connect to a remote computer and then create the >> > drive, >> > extract the data and then delete the drive and then move on to the next >> > computer. >> > >> > Thanks >> > >> > Terminator. >> >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Remote desktop can not find remote computer | Network & Sharing | |||
| Remote Desktop - copy from remote drive to local drive - DENIED! | Vista General | |||
| How to setup Username/Password for a drive in a Windows XP computer to backup files from a Vista computer? | Vista General | |||
| Vista: This Computer can't connect to the Remote Computer | Vista networking & sharing | |||
| Computer Management: Can't connect to a remote computer | Vista networking & sharing | |||