How do you run the PowerShell command - Enable-PSRemoting - globally on the desktop machines?

Hi Experts,

I have a script to gather Administrator information from each Windows 7 desktop or Windows 2008 server but I'm not sure how to run the command 'Enable-PSRemoting' globally so the script run successfully and doesn't display the 'RPC is Unavailable' error.

Thank you,
CuriousMAUserAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

McKnifeCommented:
Hi.

I'm quite sure there's a way with GPOs. Did you drill through the gpo reference, yet? http://www.microsoft.com/en-us/download/details.aspx?id=25250
0
Steve WhitcherSystems AdministratorCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CuriousMAUserAuthor Commented:
Hi Steve,

Thank you. The final comment states an important remote command, 'winrm quickconfig -q'  which needs to execute manually on every remote desktop once. Wow. Fortunately, we only have 708 desktops, the Anonymous response has 5000 systems. Yikes.

Thank you, again.
Tom
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Steve WhitcherSystems AdministratorCommented:
I wasn't at my desk yesterday, so I couldn't dig up this reference.  I thought I'd throw it out there this morning as another option.  Lee Holmes offers a script in his book "Windows Powershell Cookbook" which uses WMI to remotely enable powershell remoting.  The Powershell Cookbook module is available online and includes this script as a function "Enable-RemotePSRemoting".  Here is the script itself, if you don't want to get the module for some reason:

    ##############################################################################
    ##
    ## Enable-RemotePsRemoting
    ##
    ## From Windows PowerShell Cookbook (O'Reilly)
    ## by Lee Holmes (http://www.leeholmes.com/guide)
    ##
    ##############################################################################
    
    <#
    
    .SYNOPSIS
    
    Enables PowerShell Remoting on a remote computer. Requires that the machine
    responds to WMI requests, and that its operating system is Windows Vista or
    later.
    
    .EXAMPLE
    
    PS > Enable-RemotePsRemoting <Computer>
    
    #>
    
    param(
        ## The computer on which to enable remoting
        $Computername,
    
        ## The credential to use when connecting
        $Credential = (Get-Credential)
    )
    
    Set-StrictMode -Version 3
    
    $VerbosePreference = "Continue"
    
    $credential = Get-Credential $credential
    $username = $credential.Username
    $password = $credential.GetNetworkCredential().Password
    
    $script = @"
    
    `$log = Join-Path `$env:TEMP Enable-RemotePsRemoting.output.txt
    Remove-Item -Force `$log -ErrorAction SilentlyContinue
    Start-Transcript -Path `$log
    
    ## Create a task that will run with full network privileges.
    ## In this task, we call Enable-PsRemoting
    schtasks /CREATE /TN 'Enable Remoting' /SC WEEKLY /RL HIGHEST ``
        /RU $username /RP $password ``
        /TR "powershell -noprofile -command Enable-PsRemoting -Force" /F |
        Out-String
    schtasks /RUN /TN 'Enable Remoting' | Out-String
    
    `$securePass = ConvertTo-SecureString $password -AsPlainText -Force
    `$credential =
        New-Object Management.Automation.PsCredential $username,`$securepass
    
    ## Wait for the remoting changes to come into effect
    for(`$count = 1; `$count -le 10; `$count++)
    {
        `$output = Invoke-Command localhost { 1 } -Cred `$credential ``
            -ErrorAction SilentlyContinue
        if(`$output -eq 1) { break; }
    
        "Attempt `$count : Not ready yet."
        Sleep 5
    }
    
    ## Delete the temporary task
    schtasks /DELETE /TN 'Enable Remoting' /F | Out-String
    Stop-Transcript
    
"@
    
    $commandBytes = [System.Text.Encoding]::Unicode.GetBytes($script)
    $encoded = [Convert]::ToBase64String($commandBytes)
    
    Write-Verbose "Configuring $computername"
    $command = "powershell -NoProfile -EncodedCommand $encoded"
    $null = Invoke-WmiMethod -Computer $computername -Credential $credential `
        Win32_Process Create -Args $command
    
    Write-Verbose "Testing connection"
    Invoke-Command $computername {
        Get-WmiObject Win32_ComputerSystem } -Credential $credential

Open in new window

0
CuriousMAUserAuthor Commented:
Thank you, Steve.

Three books I have which I'm still digesting are:
PowerShell Deep Dives - Jeffery Hicks
Windows PowerShell Best Practices - Ed Wilson
PowerShell In Depth - Don Jones, Jeffery Hicks & Richard Siddaway

I'll check out the PowerShell Cookbook. Thank you.
0
McKnifeCommented:
0
CuriousMAUserAuthor Commented:
Thank you, more information, the better.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.