none
Powershell Script to Choose PC to Run Command on RRS feed

  • Question

  • Hello, 

    Working to get a powershell script running where I can run it through a normal powershell window and select the PC in the script itself. 

     param
        (       
            [parameter(Mandatory=$true)]
            [ValidateNotNullOrEmpty()]
            [String]$computer
        )


    $destpath = "\\$computer\C$\installs\.exe"
    $sourcepath = "\Source Path"

    {
            #Add Ports
           Add-PrinterPort -Name "PrinterPort" -PrinterHostAddress 127.0.0.1 -ComputerName $Computer
           #Add Print Driver
           Add-PrinterDriver -Name "Generic / Text Only" -ComputerName $Computer    
          #Add Printer
          Add-Printer -ComputerName $Computer -Name "PRINTER" -PortName "Printer" -DriverName "Generic / Text Only"

          New-Item -Path \\$computer\C$\installs\Folder -ItemType directory
          Copy-Item $sourcepath -Destination $destpath -Recurse -Verbose 
         
         }
         

    When i run this it gives me the option to choose PC but script doesnt run

    Any tips would be helpful, still gaining powershell knowledge as I go. 

    Tuesday, October 8, 2019 12:10 AM

Answers

All replies