Function Get-FileName($initialDirectory) { [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog $OpenFileDialog.initialDirectory = $initialDirectory #$OpenFileDialog.filter = "CSV (*.csv)| *.csv" ### If you want to specify file type $OpenFileDialog.ShowDialog() | Out-Null $OpenFileDialog.filename } $computername = read-host -Prompt "Enter Computer Name" $inputfile = Get-FileName "C:\temp" $inputdata = get-content $inputfile $path = '\\' + $computername + '\C$\Temp\' $SessionArgs = @{ ComputerName = $computername #Credential = Get-Credential SessionOption = New-CimSessionOption -Protocol Dcom } $MethodArgs = @{ ClassName = 'Win32_Process' MethodName = 'Create' CimSession = New-CimSession @SessionArgs Arguments = @{ CommandLine = "powershell Start-Process powershell -ArgumentList 'Enable-PSRemoting -Force'" } } Invoke-CimMethod @MethodArgs #copy item to remote computer Copy-Item -Path $inputfile -Destination $path -Force Write-Host " File Copy Done" Invoke-Command -ComputerName $computername -ScriptBlock {& cmd.exe /c "c:\Temp\MH18P02_X8055.exe"} Start-Sleep -Seconds 20 Write-Host " Now installing the printer" #$MethodArgs.Arguments = @{CommandLine = "powershell Start-Process powershell -ArgumentList 'Disable-PSRemoting -Force'" } #Invoke-CimMethod @MethodArgs #Remove-CimSession -CimSession $MethodArgs.CimSession