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 Profile photo of kvprasoon kvprasoon 1 year, 5 months ago.

  • Author
    Posts
  • #28220
    Profile photo of Soma sympli
    Soma sympli
    Participant

    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
    Profile photo of kvprasoon
    kvprasoon
    Participant

    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
    Profile photo of Wilfredo Perez
    Wilfredo Perez
    Participant

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

  • #28282
    Profile photo of Soma sympli
    Soma sympli
    Participant

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

  • #28309
    Profile photo of kvprasoon
    kvprasoon
    Participant

    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

You must be logged in to reply to this topic.