using psexec

Welcome Forums General PowerShell Q&A using psexec

This topic contains 5 replies, has 4 voices, and was last updated by

 
Participant
2 years, 3 months ago.

  • Author
    Posts
  • #54770

    Participant
    Points: 0
    Rank: Member

    Hi, unfortunately at the company I work at PSremoting is disable so I cant use it. From a list of computers how could I check to see if a executable is on a computer and then run it remotely via psexec? I also have to take into account we have a mixture of 32 bit OS and 64 bit OS computers. So depending on the OS type the executable will be located either in the C:\Program Files or C:\Program Files (x86) folders. Thanks for any help in advance.

  • #54775

    Moderator
    Points: 24
    Team Member
    Rank: Member

    Sorry I'm on my phone at the moment but you should Google for CIM_DataFile to find the executable without PS Remoting.

    I hope that helps.

  • #54941

    Participant
    Points: 0
    Rank: Member

    Hi, could you please provide an example?

  • #54956

    Participant
    Points: 0
    Rank: Member

    Get-WMIObject -Query "Select * From CIM_Datafile Where Name = 'D:\\test.txt'"

    Get-WMIObject -Query "Select * From CIM_Directory Where Name = 'D:\\data'"

  • #54975

    Participant
    Points: 0
    Rank: Member

    Her is something that I came up with, to give you an idea:

    $strcomputers = Get-Content C:\file.txt
    foreach ($cn in $strcomputers){
        $OSArch = Get-WmiObject -Class win32_OperatingSystem -ComputerName $cn | select pscomputername, OSArchitecture
           if( $OSArch.OSArchitecture -eq "64-bit")
                {Write-Output "Hello, I am using 64-bit"} 
            else
                {Write-Output "Hello, I am using 32-bit"}
    }
    

    I would ping the computers first. You will have to come up with that code. The code will have to change

  • #55125

    Participant
    Points: 0
    Rank: Member

    Cool. Thank you

The topic ‘using psexec’ is closed to new replies.