Powershell script to install Pidgin

Hello,

I want to install Pidgin in all the computers on the network and I want to do it via Powershell. I modified a script that i found and it looks like this:

$computers = Get-Content "C:\Users\administrator.INTERN\Desktop\Scripts\Pidgin\computers.txt"

foreach ($computer in $computers) {


#The location of the file  
    $Install = "\\voyager\Software\015 Messenger Clients"

#The Install string can have commands aswell
  $InstallString = "$Install\pidgin-2.10.11-offline.exe"
  
	([WMICLASS]"\\$computer\ROOT\CIMV2:Win32_Process").Create($InstallString)
#Output the install result to your Local C Drive
	Out-File -FilePath c:\Users\administrator.INTERN\Desktop\Scripts\Pidgin\installed.txt -Append -InputObject "$computer"}

But when i execute it i get this messages:

Cannot convert value "\\192.168.9.104\ROOT\CIMV2:Win32_Process" to type "System.Management.ManagementClass". Error:
"The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"
At C:\Users\administrator.INTERN\Desktop\Scripts\Pidgin\install pidgin.ps1:18 char:2
+     ([WMICLASS]"\\$computer\ROOT\CIMV2:Win32_Process").Create($InstallString)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastToWMIClass

I know nothing about scripting.

Also if it is posible , does anyone knows hot to make it so Pidgin uses the windows credentials???

Thanks

February 4th, 2015 3:26pm

You cannot install a file that is not on the remote machine.

You cannot use an IP when instancing a class.

Free Windows Admin Tool Kit Click here and download it now
February 4th, 2015 6:25pm

Hi Albercuba,

Agree with Jrv, I also recommend you can copy the .exe file to the remote computer from the network share location.

In addition, for the error "The RPC server is unavailable", please check the firewall issue on the remote computers by manually disable the firewall, and check if the issue persists.

I found this script may be helpful for you:

[CmdletBinding()]
param (
    [Parameter(ValueFromPipelineByPropertyName=$true,Position=0)] 
    [array] $ComputerName
)

Begin {
    $WorkingDir = "c:\temp"
    $Arguments = "/DS=1 /SMS=0 /L=1033 /S"
    $EXE = "pidgin-2.10.3-offline.exe"
    $Command = "$EXE $Arguments"
    $RemoteWorkingDir = "c$\Temp"

}

Process {
    
    ForEach ($Computer in $ComputerName) {
        #Create working directory in remote path
        New-Item -Path "\\$ComputerName\$RemoteWorkingDir" -ItemType Directory 
        #Copy the exe to the remote working directory
        Copy-Item -Path "$WorkingDir\$EXE" -Destination "\\$ComputerName\$RemoteWorkingDir" -Force
        $RemoteWorkingDir = ($RemoteWorkingDir).Replace("$",":")
        
        #Set up WMI and execute
        $process = [WMICLASS]"\\$ComputerName\ROOT\CIMV2:win32_process"
        $result = $process.Create("$RemoteWorkingDir\$command") 
        
        If ($result.returnValue -eq 0) {
            Write-Verbose "[$Computer]: Process execution succeeded ($RemoteWorkingDir\$Command) at $(Get-Date)"
        }
        Else {
            Write-Warning "[$Computer]: Something went wrong - process execution failed ($RemoteWorkingDir\$Command) at $(Get-Date)"
        }
    }
}

End {

} 

This script will copy the .exe file to the folder c:\temp on remote computers.

The Source file .exe is located in $WorkingDir in the script above.

Refer to:

install executable file in powershell

If there is anything else regarding this issue, please feel free to post back.

Best Regards,

Anna Wang
February 8th, 2015 11:29am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics