Get registry value; forest DCs

Welcome Forums General PowerShell Q&A Get registry value; forest DCs

Viewing 7 reply threads
  • Author
    Posts
    • #271432
      Participant
      Topics: 139
      Replies: 287
      Points: 460
      Rank: Contributor

      Having trouble getting this to run.

      ..as I can’t find out how to resolve the missing ‘)’

    • #271438
      Participant
      Topics: 9
      Replies: 677
      Points: 2,680
      Helping Hand
      Rank: Community Hero

      Why do you think it’s missing? I think you have an extra one that’s not needed. Properly format/indent and it would be easier to see where an extra/missing one is.

      The parenthesis around your command is also unnecessary.

    • #271951
      Participant
      Topics: 139
      Replies: 287
      Points: 460
      Rank: Contributor

      Thank you Doug, it runs now.

      I added some leaner output:

      …but
      1) I get a “RunspaceID” column that’s not particular useful. Any way to trim that?
      2) Anyway to sort by Domain? As it is, it’s rather random looking…domains’ DCs mixed around each other (yet the first part of the name is not alphabetical either)
      3) How do I capture in a csv, the output sorted on? I thought I would have at least the output (mangled as it was) in the requested csv.

      • This reply was modified 2 weeks, 3 days ago by Jeff Taylor.
    • #271963
      Participant
      Topics: 5
      Replies: 177
      Points: 686
      Helping Hand
      Rank: Major Contributor

      1) I get a “RunspaceID” column that’s not particular useful. Any way to trim that?

      RunspaceID and PSComputerName properties are automatic when running Invoke-Command.  There is a -HideComputerName switch which will get rid of the PSComputerName but not one just for RunspaceID.  The best way to “select” the properties you want is to pipe the output to Select-Object and put the properties you want to see in the -Property parameter.  Or you can use the -excludeProperty parameter for properties you want to exclude.

      Get-Help Select-Object

      Get-Help Invoke-Command

      2) Anyway to sort by Domain? As it is, it’s rather random looking…domains’ DCs mixed around each other (yet the first part of the name is not alphabetical either)

      Pipe output to Sort-Object and pass the properties you want to sort on to the Property parameter

      Get-Help Sort-Object

      3) How do I capture in a csv, the output sorted on? I thought I would have at least the output (mangled as it was) in the requested csv.

      Pipe output to Export-CSV

      Get-Help Export-CSV

    • #271969
      Participant
      Topics: 139
      Replies: 287
      Points: 460
      Rank: Contributor

      I believe I’ve done already in the code I posted what you’ve suggested (separately, but you don’t really indicate what order might be tripping up the efficacy of the “sort” I’m looking for, in particular).

      Your suggestions (with two separate examples of “Pipe Output to”) are in my code. The help files only account one of those situations (per cmdlet). I’m trying to get both to work together.

      And even so, when I try your suggestions by changing up the names of the various Property’s, PS balks that “a positional parameter cannot be found that accepts argument” for all of the property’s I tried (and am I’m only interested in “PCCOmputerName and/or “PerformTicketSignature”

      I’ll keep playing with it but thank you for the second set of eyes.

    • #271972
      Participant
      Topics: 5
      Replies: 177
      Points: 686
      Helping Hand
      Rank: Major Contributor

      Your pipes are inside the script block of the Invoke-Command cmdlet.  That means they are running on the remote machine, not yours.  Try it this way:

      The foreach loop is unnecessary because Invoke-Command will take an array of strings in the ComputerName parameter.

    • #271993
      Participant
      Topics: 139
      Replies: 287
      Points: 460
      Rank: Contributor

      Thanks Mike. Those two suggestions fixed both my sorting problem and formatting. Finished code:

      Your comment about “foreach unnecessary…because Invoke-Command will take an array of strings in the ComputerName parameter.” is because this portion of the Help file, correct?

      Invoke-Command
      [[-ComputerName] <String[]>]

    • #272002
      Participant
      Topics: 5
      Replies: 177
      Points: 686
      Helping Hand
      Rank: Major Contributor

      Yep.  If the documentation puts [] after the argument type that means it will accept an array of that type.  Glad you got it working.

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