locked
Find PS version and remoting enabled multiple servers RRS feed

  • Question

  • Morning all,

    I just trying to get PS version and remoting enabled in multiple servers.

    Tried first PS version, looks like it is returning invalid version. It returning major 1, but when I checked inside the server  it shows 5.

    $computers = Get-Content "\Server.txt"
    
    Invoke-Command -ComputerName $computers -ScriptBlock{
        get-host | select-object -expandproperty version    
    
        
    }|export-csv -Path '\PS_Version.csv' -NoTypeInformation
    

    Tuesday, April 28, 2020 10:25 AM

Answers

  • I see the results that you initially reported, but the script that I posted works for me. 

    What results does this give you?

    $computers = Get-Content ".\Server.txt"
    'Analyzing these computers.'
    $computers
    ''
    'Querying $psversiontable.PSVersion'
    Invoke-Command -ComputerName $computers -ScriptBlock{
           $psversiontable.PSVersion  
    }
    ''
    'Querying host.version '
    Invoke-Command -ComputerName $computers -ScriptBlock{
           (get-host).version 
    }

    Tuesday, April 28, 2020 3:23 PM

All replies

  • $computers = Get-Content ".\Server.txt"
    Invoke-Command -ComputerName $computers -ScriptBlock{
           $psversiontable.PSVersion  
    }|export-csv -Path '.\PS_Version.csv' -NoTypeInformation
    
    I used ".\" on the file names to reference the current directory. 
    • Marked as answer by SQL_VJ Tuesday, April 28, 2020 1:28 PM
    • Unmarked as answer by SQL_VJ Tuesday, April 28, 2020 1:28 PM
    Tuesday, April 28, 2020 12:30 PM
  • Sorry, I have used FQDN \\share\server.txt, not display here. It is not taking the correct version of PS from remote server.
    Tuesday, April 28, 2020 1:29 PM
  • I see the results that you initially reported, but the script that I posted works for me. 

    What results does this give you?

    $computers = Get-Content ".\Server.txt"
    'Analyzing these computers.'
    $computers
    ''
    'Querying $psversiontable.PSVersion'
    Invoke-Command -ComputerName $computers -ScriptBlock{
           $psversiontable.PSVersion  
    }
    ''
    'Querying host.version '
    Invoke-Command -ComputerName $computers -ScriptBlock{
           (get-host).version 
    }

    Tuesday, April 28, 2020 3:23 PM