Rename multiple computers, after fetching data requested and save the data too

Welcome Forums General PowerShell Q&A Rename multiple computers, after fetching data requested and save the data too

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

 
Participant
3 years, 3 months ago.

  • Author
    Posts
  • #28220

    Participant
    Points: 76
    Rank: Member

    I have been trying to use the below code and it doesn't seem to work , I get error stating "The RPC server is unavailable"

    computer.csv contains 2 columns "OLDNAME" & " NEWNAME"

    I'm trying to rename multiple computers however before the rename happens I want ipconfig and services info collected and saved in a text or html format.

    Import-Csv -Path C:\Users\Wicky\Desktop\COMPUTERS.csv| ForEach-Object { Get-WMIObject Win32_Service -ComputerName $_.OLDNAME ; Get-WMIObject Win32_process -ComputerName $_.OLDNAME ;
    Invoke-Command -ComputerName $_.OLDNAME {systeminfo} ;Get-ADOrganizationalUnit -ComputerName $_.OLDNAME ;
    | Rename-Computer -DomainCredential $cred -ComputerName $_.OLDNAME -NewName $_.NEWNAME}|
    Out-File rename.txt

    could you please help editing my script to work.TIA

  • #28222

    Participant
    Points: 606
    Helping Hand
    Rank: Major Contributor

    Hi Soma,
    For Collecting Information and To do Invoke-command To Remote computers, Winrm Has To be enabled in remote computers.
    enabling WinRM.

    Enable-PSremoting -Force

    The best way to get known about PS Remoting
    https://www.penflip.com/powershellorg/secrets-of-powershell-remoting

    Regards.,
    kvprasoon

  • #28224

    Participant
    Points: 0
    Rank: Member

    The error "The RPC server is unavailable" is because you will need to enable remoting.

  • #28282

    Participant
    Points: 76
    Rank: Member

    I'm able to restart the computer, take ps-session . remoting is enabled, still I get the error

  • #28309

    Participant
    Points: 606
    Helping Hand
    Rank: Major Contributor

    Hi Soma,
    You can try by enabling
    Windows Management Instrumentation (WMI-In) in firewall inbound rule(Select proper profile-Domain, Private or All).
    I was able to recreate the same by disabling it in remote machine.

    Regards.,
    kvprasoon

The topic ‘Rename multiple computers, after fetching data requested and save the data too’ is closed to new replies.