locked
Pulling Adobe Flash player versions RRS feed

  • Question

  • I would like to pull the version of Adobe Flash for all computer in certain OU's in ad using a script I modified from one of my old ones but I don't know if I should use the Get-wmiobject cmdlet and if so where in the script below can I pipe to do another search?

    $oulist = 'OU=Computers,OU=BOS,DC=domain,DC=domain1,DC=com','CN=Computers,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=DC,DC=domain,DC=domain1,DC=com','OU=Computers,OU=DEL,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=HBG,DC=domain,DC=domain1,DC=com','OU=Computers,OU=NRK,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=PHL,DC=domain,DC=domain1,DC=com','OU=Computers,OU=PIT,DC=domain,DC=domain1,DC=com',
    'OU=Computers IT,OU=PIT,DC=domain,DC=domain1,DC=com','OU=Computers,OU=RIC,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=TTN,DC=domain,DC=domain1,DC=com','OU=Computers,OU=WNY,DC=domain,DC=domain1,DC=com'
    
    $oulist | ForEach {
    
        Get-ADComputer -Filter * -Properties Name -SearchBase $_
    
        } | Select Name |
            Export-csv 'C:\users\eorosz\desktop\Adobe Flash Version.csv' -NotypeInformation

    Thursday, April 14, 2016 9:44 PM

Answers

  • You have the $cred = Get-Credential in the ForEach loop, therefore you will get prompted for your credentials for each computer in the array.


    • Edited by _P_M_ Tuesday, April 19, 2016 8:40 PM
    • Proposed as answer by Wendy Jiang Monday, April 25, 2016 8:34 AM
    • Marked as answer by Yan Li_ Monday, May 9, 2016 7:17 AM
    Tuesday, April 19, 2016 8:17 PM

All replies

  • Why another search. Each computer can have only one flash player.

    You need to do a ForEach on the results of the Get-Computer and use the name to do you Get-WmiObject.


    \_(ツ)_/

    Thursday, April 14, 2016 10:37 PM
  • I added the Foreach line but I don't think I used it correctly then added the Get-Wmiobject  cmdlet but I only want to get the Adobe Flash info for ever user computer on the domain. 

    $oulist = 'OU=Computers,OU=BOS,DC=domain,DC=domain1,DC=com','CN=Computers,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=DC,DC=domain,DC=domain1,DC=com','OU=Computers,OU=DEL,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=HBG,DC=domain,DC=domain1,DC=com','OU=Computers,OU=NRK,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=PHL,DC=domain,DC=domain1,DC=com','OU=Computers,OU=PIT,DC=domain,DC=domain1,DC=com',
    'OU=Computers IT,OU=PIT,DC=domain,DC=domain1,DC=com','OU=Computers,OU=RIC,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=TTN,DC=domain,DC=domain1,DC=com','OU=Computers,OU=WNY,DC=domain,DC=domain1,DC=com'
    
    $oulist | ForEach {
    
        Get-ADComputer -Filter * -Properties Name -SearchBase $_
       
        } | Select Name
        
         | ForEach {
    
         Get-WmiObject -Class Win32_Product -Property Name,Vendor,Version
    
            Export-csv 'C:\users\eorosz\desktop\Adobe Flash Version.csv' -NotypeInformation

    Friday, April 15, 2016 1:44 PM
  • Hi, you can use the where functionality, the below should help you in the right direction..

    Get-WmiObject -Class Win32_Product -Property Name,Vendor,Version | where {$_.Name -like "Adobe Flash*"}


    • Proposed as answer by Wendy Jiang Thursday, April 28, 2016 9:18 AM
    • Unproposed as answer by Wendy Jiang Thursday, April 28, 2016 9:19 AM
    Friday, April 15, 2016 1:53 PM
  • Okay great that will give me what I need for the adobe info but i'm getting this error. Do I still need the ForEach to separate the two different cmdlets? If so should I use | foreach } or foreEach-object

    Get-ADComputer : The supplied distinguishedName must belong to one of the 
    following partition(s): 'DC=domain,DC=domain1,DC=com , 
    CN=Configuration,DC=domain,DC=domain1,DC=com , 
    CN=Schema,CN=Configuration,DC=domain,DC=domain1,DC=com , 
    DC=DomainDnsZones,DC=domain,DC=domain1,DC=com , 
    DC=ForestDnsZones,DC=domain,DC=domain1,DC=com'.
    At line:10 char:5
    +     Get-ADComputer -Filter * -Properties Name -SearchBase $_



    • Edited by eorosz Friday, April 15, 2016 2:07 PM
    Friday, April 15, 2016 2:04 PM
  • Hi, you can use the where functionality, the below should help you in the right direction..

    Get-WmiObject -Class Win32_Product -Property Name,Vendor,Version | where {$_.Name -like "Adobe Flash*"}


    Very inefficient. With WMI we would use a filter:

    Get-WmiObject -Class Win32_Product -Filter 'Name like "Adobe Flash%"'


    \_(ツ)_/

    Friday, April 15, 2016 3:09 PM
  • Okay great that will give me what I need for the adobe info but i'm getting this error. Do I still need the ForEach to separate the two different cmdlets? If so should I use | foreach } or foreEach-object

    Get-ADComputer : The supplied distinguishedName must belong to one of the 
    following partition(s): 'DC=domain,DC=domain1,DC=com , 
    CN=Configuration,DC=domain,DC=domain1,DC=com , 
    CN=Schema,CN=Configuration,DC=domain,DC=domain1,DC=com , 
    DC=DomainDnsZones,DC=domain,DC=domain1,DC=com , 
    DC=ForestDnsZones,DC=domain,DC=domain1,DC=com'.
    At line:10 char:5
    +     Get-ADComputer -Filter * -Properties Name -SearchBase $_

    TO retrieve remote values you must specify a computer name:

    Get-WmiObject -Class Win32_Product -Filter 'Name like "Adobe Flash%"' -Computer $remotePC


    \_(ツ)_/

    • Proposed as answer by jrv Tuesday, April 19, 2016 7:43 PM
    Friday, April 15, 2016 3:10 PM
  • You need to pay attention to how a pipeline works.  It must be enumerates or passed into. In this case you must enumerate all elements.

    $oulist = @(
    'OU=Computers,OU=BOS,DC=domain,DC=domain1,DC=com',
    'CN=Computers,DC=domain,DC=domain1,DC=com', 'OU=Computers,OU=DC,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=DEL,DC=domain,DC=domain1,DC=com', 'OU=Computers,OU=HBG,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=NRK,DC=domain,DC=domain1,DC=com', 'OU=Computers,OU=PHL,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=PIT,DC=domain,DC=domain1,DC=com', 'OU=Computers IT,OU=PIT,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=RIC,DC=domain,DC=domain1,DC=com', 'OU=Computers,OU=TTN,DC=domain,DC=domain1,DC=com',
    'OU=Computers,OU=WNY,DC=domain,DC=domain1,DC=com' ) $oulist | ForEach-Object { Get-ADComputer -Filter * -SearchBase $_ | ForEach-Object{ Get-WmiObject -Class Win32_Product -Filter 'Name like "Adobe Flash%"' -Computer $_.Name } } | select pscomputername, caption, version

    I would test your OUs one at a time to be sure they are typed correctly.  You must also have a trust and permission cross domain.

    I would just query the GC for all computers as it would be faster.

    Get-AdComputer -filter * -Server GC-server:3368

    https://technet.microsoft.com/en-us/library/dd378945%28v=ws.10%29.aspx?f=255&MSPPError=-2147217396


    \_(ツ)_/


    • Edited by jrv Friday, April 15, 2016 3:23 PM
    • Proposed as answer by Wendy Jiang Thursday, April 28, 2016 9:19 AM
    Friday, April 15, 2016 3:21 PM
  • If you just want all computers in the domain then don't specify a search base.  This gets all computers:
    Get-AdComputer -Filter *

    \_(ツ)_/

    Friday, April 15, 2016 3:25 PM
  • When it is run I get this error. Which I believe I don't have rights to query the remote pc's 

    Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 
    (E_ACCESSDENIED))
    At line:12 char:3
    +         Get-WmiObject -Class Win32_Product -Filter 'Name like "Adobe 
    Flash%"' -Compute ...
    +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Get-WmiObject], UnauthorizedA 
       ccessException
        + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Pow 
       erShell.Commands.GetWmiObjectCommand

    Friday, April 15, 2016 3:39 PM
  • You have to be an administrator on the remote system.


    \_(ツ)_/

    Friday, April 15, 2016 3:40 PM
  • Now I have a special local admin account for all pc's on the domain is there away I can add an impersonate command for that account?
    Friday, April 15, 2016 3:43 PM
  • If they all have the same name and password yes.

    $cred=Get-Credential localhost\adminname  # actually use "localhost" as the domain name

    Get-WMIObject ... -Credential $cred


    \_(ツ)_/



    • Edited by jrv Friday, April 15, 2016 3:47 PM
    Friday, April 15, 2016 3:45 PM
  • Well actually they don't we use a unique username and password. 
    Friday, April 15, 2016 3:49 PM
  • Better yet is there a command that I can use to prompt me for my admin creds?
    Friday, April 15, 2016 4:01 PM
  • Just enter:

    $cred=Get-Credential

    This will prompt.


    \_(ツ)_/

    Friday, April 15, 2016 4:28 PM
  • That worked great. Before I do a mass query I would like to limit it to a few computers first would in just a change the oulist to a few computer names or will the first part of the code need to be rewritten?

    $computers = @('D-MJ000###','D-MJ000***'
    )
    $computers | 
    ForEach-Object {
        Get-ADComputer -Identity   
    $cred=Get-Credential
    		Get-WmiObject -Class Win32_Product -Filter 'Name like "Adobe Flash%"' $computers Name -Credential $cred
    	}
    
     select pscomputername, caption, version
                Export-csv 'C:\users\eorosz\desktop\Adobe Flash Version.csv' -NotypeInformation


    • Edited by eorosz Friday, April 15, 2016 5:11 PM
    Friday, April 15, 2016 4:47 PM
  • Hi,
    Based on my test, you could change the oulist to computer names. I have not re-written it.

    Regards,
    Wendy


    Please remember to mark the replies as answers if they help and un-mark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, April 18, 2016 8:02 AM
  • Okay well the code above doesn't work after I supply my admin creds. So I was hoping that I could use this modified code to pull information for one or two computers at a time for testing. 

    $computers = @('D-MJ000F6A'
    )
    $computers | ForEach {
    $cred=Get-Credential
        Get-ItemProperty "HKLM:\SOFTWARE\Macromedia\FlashPlayer" -Credential $cred
        
     
        }| Select-Object pschildname, currentversion 

    The problem is I get this error. 

    The provider does not support the use of credentials. Perform the operation again 
    without specifying credentials.
    At line:5 char:5
    +     Get-ItemProperty "HKLM:\SOFTWARE\Macromedia\FlashPlayer" -Credential $cred
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotImplemented: (:) [], PSNotSupportedException
        + FullyQualifiedErrorId : NotSupported

    Tuesday, April 19, 2016 7:38 PM
  • Get-ItemProperty?  Why would you expect that to work?  You are still only querying the local computer.


    \_(ツ)_/

    Tuesday, April 19, 2016 7:42 PM
  • Get-WmiObject Win32_Product -Filter 'Name like "Adobe Flash%"' -Computer $remotePC -Credential $creds


    \_(ツ)_/


    • Edited by jrv Tuesday, April 19, 2016 7:45 PM
    Tuesday, April 19, 2016 7:44 PM
  • When I supply my admin creds I get this error

    Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is 
    null or empty. Provide an argument that is not null or empty, and then try the command 
    again.
    At line:5 char:78
    +     Get-WmiObject Win32_Product -Filter 'Name like "Adobe Flash%"' -Computer $re ...
    +                                                                              ~~~
        + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindingValida 
       tionException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Co 
       mmands.GetWmiObjectCommand
    


    Tuesday, April 19, 2016 7:52 PM
  • Post your entire code in the thread - you have a variable wrong somewhere.
    Tuesday, April 19, 2016 7:57 PM
  • You have to supply values for the variables. 

    \_(ツ)_/

    Tuesday, April 19, 2016 7:58 PM
  • $computers = @('D-MJ000F6A'
    )
    $computers | ForEach {
    $cred=Get-Credential
        Get-WmiObject Win32_Product -Filter 'Name like "Adobe Flash%"' -Computer $remotePC -Credential $creds
     
        }| Select-Object pschildname, currentversion

    Tuesday, April 19, 2016 8:00 PM
  • You are using the variable $remotePC that does not exist.

    You are also using the variable $cred for Get-Credential but then later you use $creds.  You have to pay closer attention to your variables.

    • Edited by _P_M_ Tuesday, April 19, 2016 8:07 PM
    Tuesday, April 19, 2016 8:03 PM
  • Change this:

    Get-WmiObject Win32_Product -Filter 'Name like "Adobe Flash%"' -Computer $remotePC -Credential $cred

    To this:

    Get-WmiObject Win32_Product -Filter 'Name like "Adobe Flash%"' -Computer $computers -Credential $cred


    • Edited by _P_M_ Tuesday, April 19, 2016 8:05 PM
    • Proposed as answer by Wendy Jiang Monday, April 25, 2016 8:34 AM
    Tuesday, April 19, 2016 8:05 PM
  • Now should I be prompted twice to enter my credentials? The first box is Supply Values for the following parameters:

    Then it ask "Enter your Credentials. Which in this case I enter the same admin account info twice. 

    Tuesday, April 19, 2016 8:09 PM
  • You have the $cred = Get-Credential in the ForEach loop, therefore you will get prompted for your credentials for each computer in the array.


    • Edited by _P_M_ Tuesday, April 19, 2016 8:40 PM
    • Proposed as answer by Wendy Jiang Monday, April 25, 2016 8:34 AM
    • Marked as answer by Yan Li_ Monday, May 9, 2016 7:17 AM
    Tuesday, April 19, 2016 8:17 PM