Powershell 3.0 Remoting

Welcome Forums General PowerShell Q&A Powershell 3.0 Remoting

This topic contains 20 replies, has 2 voices, and was last updated by

 
Participant
4 years, 11 months ago.

  • Author
    Posts
  • #12056

    Participant
    Points: 0
    Rank: Member

    If I am connected to a system [Enter-PSSession -ComputerName ] and I run a certain command I get an WARNING saying "WARNING: You haven't privileges to make this. Try start an elevated Windows Powershell console." I am a domain admin and my domain account is in the local admin group on the computer. Is there a way to run commands in an elevated console?

  • #12057

    Member
    Points: 0
    Rank: Member

    What command are you running? That warning doesn't look like anything I'd expect to see from a command Microsoft provides. It's possible that there's a problem in a script or function, and the error message is somewhat misleading.

    If you're using a domain account, UAC (elevation) isn't a factor for remote connections. If you were authenticating as a local account on the remote computer, then there is a setting to filter out the Administrators group membership, which is on by default and might be a factor. (see http://support.microsoft.com/kb/942817)

  • #12059

    Member
    Points: 0
    Rank: Member

    Please be more specific; which command, and what parameters did you pass it?

  • #12060

    Participant
    Points: 0
    Rank: Member

    I have connected to the remote machine "C1243-01" from my workstation using the following command:
    Enter-PSSession -ComputerName c1243-01

    Hide-WUUpdate -Title "*Language Pack"

    Confirm
    Are you sure you want to perform this action?
    Performing operation "Hide Latvian Language Pack – Windows 7 Service Pack 1 for x64-based Systems (KB2483139)?" on Target "C1243-01".
    [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): a
    WARNING: You haven't privileges to make this. Try start an eleated Windows PowerShell console.
    parsing "*Language Pack" – Quantifier {x,y} following nothing.
    At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\pswindowsupdate\Hide-WUUpdate.ps1:455 char:10
    + If($Update.Title -notmatch $Title)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException

  • #12061

    Participant
    Points: 0
    Rank: Member

    Another example:

    [c1243-01]: PS C:\Users\emanuelg\Documents> Hide-WUUpdate -KBArticleID KB2483139

    Confirm
    Are you sure you want to perform this action?
    Performing operation "Hide Latvian Language Pack – Windows 7 Service Pack 1 for x64-based Systems (KB2483139)?" on Target "C1243-01".
    [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): y
    WARNING: You haven't privileges to make this. Try start an eleated Windows PowerShell console.

  • #12062

    Member
    Points: 0
    Rank: Member

    OK, I'm looking through the source code for that module now. I see that the module has remoting capabilities built-in; have you tried running Hide-WUUpdate -Title "*Language Pack" -ComputerName "C1243-01" from your computer, without using Enter-PSSession?

    For whatever reason, the error handling code in this part of the module completely throws out the error message and writes that one instead. You can edit this section of Hide-WUUpdate.ps1 to get some more information:

    							
    If($pscmdlet.ShouldProcess($Computer,"$StatusName $($Update.Title)?")) 
    {
        Try
        {
            $Update.IsHidden = $HideStatus
        }
        Catch
        {
            Write-Warning "You haven't privileges to make this. Try start an eleated Windows PowerShell console.`r`nError: $($_ | Out-String)"
        }
    								
    } #$pscmdlet.ShouldProcess($Computer,"Hide $($Update.Title)?")
    

    I changed $env:COMPUTERNAME to $Computer in the ShouldProcess line (a slight bug in their code, but not something that would affect overall functionality), and added some extra information to the Write-Warning line (everything after the word "console.")

  • #12063

    Participant
    Points: 0
    Rank: Member

    Hide-WUUpdate -Title "*Language Pack" -ComputerName c1243-01

    Exception calling "CreateInstance" with "1" argument(s): "Retrieving the COM class factory for remote component with CLSID
    {4CB43D7F-7EEE-4906-8698-60DA1C38F2FE} from machine c1243-01 failed due to the following error: 800706ba c1243-01."
    At E:\Profile\My Documents\WindowsPowerShell\Modules\PSWindowsUpdate\Hide-WUUpdate.ps1:208 char:6
    + $objSession = [activator]::CreateInstance([type]::GetTypeFromProgID("Micro ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : COMException

    You cannot call a method on a null-valued expression.
    At E:\Profile\My Documents\WindowsPowerShell\Modules\PSWindowsUpdate\Hide-WUUpdate.ps1:212 char:5
    + $objSearcher = $objSession.CreateUpdateSearcher()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

  • #12064

    Member
    Points: 0
    Rank: Member

    Looks like that error code is "The RPC server is unavailable." You may have a firewall (including Windows Firewall on the target computer) blocking that traffic.

  • #12065

    Participant
    Points: 0
    Rank: Member

    Still getting this error: (I'm purposely using a * wildcard in front of Language Pack in the string so I can hide them all)

    Hide-WUUpdate -Title "*Language Pack" -ComputerName c1243-01

    parsing "*Language Pack" – Quantifier {x,y} following nothing.
    At E:\Profile\My Documents\WindowsPowerShell\Modules\PSWindowsUpdate\Hide-WUUpdate.ps1:455 char:10
    + If($Update.Title -notmatch $Title)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException

    Confirm
    Are you sure you want to perform this action?
    Performing operation "Hide Latvian Language Pack – Windows 7 Service Pack 1 for x64-based Systems (KB2483139)?" on Target "MUGL".
    [Y] Yes [A] Yes to All [N] No [L] No to All Suspend [?] Help (default is "Y"):
    WARNING: You haven't privileges to make this. Try start an eleated Windows PowerShell console.
    parsing "*Language Pack" – Quantifier {x,y} following nothing.
    At E:\Profile\My Documents\WindowsPowerShell\Modules\PSWindowsUpdate\Hide-WUUpdate.ps1:455 char:10
    + If($Update.Title -notmatch $Title)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException

  • #12067

    Participant
    Points: 0
    Rank: Member

    I think I've figured it out. It seems my search criteria was not complete. I was searching for the -Title as "*Language Pack" when the Title is something like (French Language Pack – Windows 7 Service Pack 1 for x64-based Systems (KB2483139)). This means I need a wild card at the end of my search criteria too ( -Title "*Language Pack*)

  • #12069

    Participant
    Points: 0
    Rank: Member

    Based on your reg expression versus mine maybe it is the "double quotes" making it a literal

  • #12070

    Member
    Points: 0
    Rank: Member

    That would be true if they were using the -like operator, but they're using -match. Your Title parameter has to be a legal regular expression, which would be '.*Language Pack.*', though just 'Language Pack' would work fine as well.

  • #12071

    Member
    Points: 0
    Rank: Member

    Single / Double quotes don't matter in this case; the string doesn't contain any characters that would cause a problem either way.

  • #12073

    Participant
    Points: 0
    Rank: Member

    I think I spoke too soon. I made the changes to the file on my workstation as well as the remote PC and I still get the following:

    [c1243-01]: PS C:\Users\emanuelg\Documents> Hide-WUUpdate -Title 'Language Pack'

    Confirm
    Are you sure you want to perform this action?
    Performing operation "Hide Latvian Language Pack – Windows 7 Service Pack 1 for x64-based Systems (KB2483139)?" on Target "C1243-01"
    [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): y
    WARNING: You haven't privileges to make this. Try start an eleated Windows PowerShell console.

    Confirm
    Are you sure you want to perform this action?
    Performing operation "Hide Czech Language Pack – Windows 7 Service Pack 1 for x64-based Systems (KB2483139)?" on Target "C1243-01".
    [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): y
    WARNING: You haven't privileges to make this. Try start an eleated Windows PowerShell console.

  • #12077

    Participant
    Points: 0
    Rank: Member

    Here you go (Sorry, I missed part of the error line):

    [c1243-01]: PS C:\Users\emanuelg\Documents> Hide-WUUpdate -Title 'Language Pack'

    Confirm
    Are you sure you want to perform this action?
    Performing operation "Hide Latvian Language Pack – Windows 7 Service Pack 1 for x64-based Systems (KB2483139)?" on Target
    [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): y
    WARNING: You haven't privileges to make this. Try start an eleated Windows PowerShell console.
    Error: Exception setting "IsHidden": "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
    At C:\windows\system32\windowspowershell\v1.0\Modules\PSWindowsUpdate\Hide-WUUpdate.ps1:529 char:10
    + $Update.IsHidden = $HideStatus
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : CatchFromBaseAdapterSetValueTI

  • #12084

    Member
    Points: 0
    Rank: Member

    Out of curiosity, have you tried logging on to this computer directly and running that command? I'm not sure if PS Remoting is a factor here, or if it's just a problem with permissions somewhere.

  • #12133

    Participant
    Points: 0
    Rank: Member

    I just verified I can run the command locally on the machine, but not using PS Remoting. Is there a way I can use PS Remoting to connect to a machine as the local administrator instead of my domain credentials? I can't seem to successfully connect as the local admin. When I use remote desktop I would do something like %hostname%\administrator but I can't get that to work using PS Remoting.

  • #12134

    Participant
    Points: 0
    Rank: Member

    When you use PS Remoting does it run powershell in elevated mode?

  • #12058

    Participant
    Points: 0
    Rank: Member

    I am running one of the commands in the PSWindowsUpdate module. To be more specific I am trying to hide particular updates.

  • #12066

    Member
    Points: 0
    Rank: Member

    I'm not seeing any new information after that Warning statement; did you make the changes I suggested earlier?

    It looks like they're using the Title parameter as a regular expression. It would have been better for them to define that parameter as a [regex] instead of a [string], but you can work with it. If you just pass a value of 'Language Pack', it will match any title that contains those words. The leading asterisk is unnecessary (though if you wanted to use one, you would have to do something like '.*Language Pack' to make it a valid regular expression.)

  • #12074

    Member
    Points: 0
    Rank: Member

    That's why I suggested this change to Hide-WUUpdate.ps1 earlier. It should give you more information about exactly what error is happening:

    							
    If($pscmdlet.ShouldProcess($Computer,"$StatusName $($Update.Title)?")) 
    {
        Try
        {
            $Update.IsHidden = $HideStatus
        }
        Catch
        {
            Write-Warning "You haven't privileges to make this. Try start an eleated Windows PowerShell console.`r`nError: $($_ | Out-String)"
        }
    								
    } #$pscmdlet.ShouldProcess($Computer,"Hide $($Update.Title)?")
    

The topic ‘Powershell 3.0 Remoting’ is closed to new replies.