Powershell Script to find PSremote enabled

Welcome Forums General PowerShell Q&A Powershell Script to find PSremote enabled

Viewing 7 reply threads
  • Author
    Posts
    • #207528
      Participant
      Topics: 7
      Replies: 16
      Points: 109
      Rank: Participant

      Hi, Could you anyone help me out how to find PSremote enabled or not and .NET version on multiple computers using a single powershell script and export them into a csv.

      Thanks in advance.

    • #207555
      Moderator
      Topics: 3
      Replies: 218
      Points: 1,188
      Helping Hand
      Rank: Community Hero

      Hi Jeevan,

      Did you try anything? Please put down anything you have tried so far, then we can assist you further towards your requirements.

      Thank you.

    • #207570
      Participant
      Topics: 7
      Replies: 16
      Points: 109
      Rank: Participant

      Hi Kiran,

      Below is the one that i tried to get .NET version. I am finding it little difficult to get the other half of my requirement into my script.

      GetContent Path “c:\temp\servers.csv” | ConvertFromCsv | ForEachObject Process { InvokeCommand ComputerName $_.Name ScriptBlock { GetChildItem ‘HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP’ }

      }

       

    • #207633
      Participant
      Topics: 6
      Replies: 93
      Points: 427
      Helping Hand
      Rank: Contributor

      Look into Test-WSMan

    • #207804
      Moderator
      Topics: 3
      Replies: 218
      Points: 1,188
      Helping Hand
      Rank: Community Hero

      Hi Jeevan,

      Try this one…

      $ScriptBlock = [scriptblock]::Create({
          $RegistryPath = 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'
          $Release = Get-ItemProperty -Path $RegistryPath -ErrorAction SilentlyContinue | ForEach-Object Release
          [PSCustomObject]@{
                  DotNetVersion = $(
                  switch ($release) {
                      ({ $_ -ge 528040 }) { '4.8'; break }
                      ({ $_ -ge 461808 }) { '4.7.2'; break }
                      ({ $_ -ge 461308 }) { '4.7.1'; break }
                      ({ $_ -ge 460798 }) { '4.7'; break }
                      ({ $_ -ge 394802 }) { '4.6.2'; break }
                      ({ $_ -ge 394254 }) { '4.6.1'; break }
                      ({ $_ -ge 393295 }) { '4.6'; break }
                      ({ $_ -ge 379893 }) { '4.5.2'; break }
                      ({ $_ -ge 378675 }) { '4.5.1'; break }
                      ({ $_ -ge 378389 }) { '4.5'; break }
                      default { '.Net installed/updated' }
                  }
              )
              IsRemotingEnabled = -not [string]::IsNullOrEmpty((Test-WsMan))
          } 
      })
      
      $Servers = Get–Content –Path 'c:\temp\servers.csv' | ConvertFrom–Csv | ForEach-Object Name
      Invoke-Command -ComputerName $Servers -ScriptBlock $ScriptBlock | Select-Object -Property DotNetVersion, IsRemotingEnabled, PSComputerName

      Thank you.

    • #207858
      Participant
      Topics: 7
      Replies: 16
      Points: 109
      Rank: Participant

      Hi Kiran, I got the below error.

      Get–Content : The term ‘Get–Content’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

      At line:24 char:12

      + $Servers = Get–Content –Path ‘c:\temp\servers.csv’ | ConvertFrom–Csv | ForEach-O …

      + ~~~~~~~~~~~

      + CategoryInfo : ObjectNotFound: (Get–Content:String) [], CommandNotFoundException

      + FullyQualifiedErrorId : CommandNotFoundException

      Invoke-Command : Cannot validate argument on parameter ‘ComputerName’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

      At line:25 char:30

      + Invoke-Command -ComputerName $Servers -ScriptBlock $ScriptBlock | Select-Object …

      + ~~~~~~~~

      + CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException

      + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand

       

    • #208083
      Moderator
      Topics: 3
      Replies: 218
      Points: 1,188
      Helping Hand
      Rank: Community Hero
      Try with full path…
      Microsoft.PowerShell.Management\Get-Content

      Thank you.

      • This reply was modified 2 months, 4 weeks ago by Kiran.
      • This reply was modified 2 months, 4 weeks ago by Kiran.
    • #209397
      Participant
      Topics: 7
      Replies: 16
      Points: 109
      Rank: Participant

      Thank you..! It works fine now.

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