Running a script remote

Welcome Forums General PowerShell Q&A Running a script remote

Viewing 3 reply threads
  • Author
    Posts
    • #271792
      Participant
      Topics: 4
      Replies: 4
      Points: 44
      Rank: Member

      I’m in need of some help running a script remotely to a server.

      I need to convert all of my commands to use a parameter called $computername.  The name of my script is get-computerstatus.ps1.

      I know I can run it like the command below, but I’m stuck with the above.

       

      • This topic was modified 2 weeks, 2 days ago by Andrzac79.
      • This topic was modified 2 weeks, 2 days ago by Andrzac79.
      • This topic was modified 2 weeks, 1 day ago by Andrzac79.
    • #271885
      Participant
      Topics: 5
      Replies: 170
      Points: 656
      Helping Hand
      Rank: Major Contributor

      It would help if you provided some code to look at.  Have you reviewed Get-Help about_parameters

    • #271891
      Participant
      Topics: 4
      Replies: 4
      Points: 44
      Rank: Member
      #Determine Operating System Information and Output only Name,BuildNumber,Version
      get-ciminstance -class win32_operatingsystem | format-list Name,BuildNumber,version
      #Determine Processor Information and Output only Device ID, Name, MaxClockSpeed
      get-ciminstance -class CIM_processor | format-list DeviceID,Name,MaxClockSpeed
      #Determine IP Address Configuration
      get-ciminstance win32_networkadapterconfiguration | format-table ipaddress,subnetmask,dhcp,defaultgateway
      #Acquire DNS Client Server address and output it
      Get-DnsClientServerAddress | format-list ServerAddresses
      #Determine the amount of system memory in GB
      get-ciminstance win32_computersystem | foreach {$_.TotalPhysicalMemory /1GB}
      #Determine the amount of of free space (GB) for the c:\ drivey
      Get-CimInstance -ClassName cim_logicaldisk | Where-Object {$_.FreeSpace} |
      Select-Object @{n=’FreeSpace’;exp={“{0:N2} GB” -f ($_.FreeSpace / 1GB)}},DeviceID
      #Determine last bootup date/time and output computer’s name and last boot time
      Get-CimInstance win32_operatingsystem | select name,lastbootuptime
      #Determine last user login date & time.  Output the username and last logon date/time
      get-localuser | where-object {$_.Lastlogon} | select-object Name,Lastlogon
      #Retrieve all user accounts and output the account name
      get-localuser| format-list name
      #Determine installed hotfixes & updates.  Output only the hotfix ID
      get-hotfix | format-list hotfixid
      #List all installed applications and output as name,vendor,version
      get-ciminstance -class WIn32_product | format-list Name,Vendor,Version
    • #271900
      Participant
      Topics: 5
      Replies: 170
      Points: 656
      Helping Hand
      Rank: Major Contributor

      If you must use a computername parameter, here’s what I would do.

      Then you would call your script like this:

      But if you have the flexibility, all you really need to do is use your current script like this:

       

Viewing 3 reply threads
  • You must be logged in to reply to this topic.