Add Custom Variable to Select-Object

Welcome Forums General PowerShell Q&A Add Custom Variable to Select-Object

Viewing 4 reply threads
  • Author
    Posts
    • #253691
      Participant
      Topics: 1
      Replies: 2
      Points: 15
      Rank: Member

      Hi,

      im trying to get the free Disk Size of 20 Servers into a .csv.

      I found the following script but the hostname is missing as a row. How can i add the computer variable into the select-object or my .csv?

       

      Thx

      Blum0r

      • This topic was modified 3 weeks, 4 days ago by Blum0r09.
      • This topic was modified 3 weeks, 4 days ago by Blum0r09.
    • #253709
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      Bon,, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

      When you post code, error messages, sample data or console output format it as code, please.
      In the “Text” view you can use the code tags “CODE“, in the “Visual” view you can use the format template “Preformatted“. You can go back edit your post and fix the formatting – you don’t have to create a new one.
      Thanks in advance.

      You should not use Get-WMIObject anymore. User Get-CimInstance instead. And you don’t need a loop. Get-CimInstance is able to take an array of computer names.

      The forum software seems a little buggy. So please remove the “crayon .. inline = true” stuff and replace the “& # 0 3 9 ;” with single quotes. 😉

      • This reply was modified 3 weeks, 3 days ago by James Petty.
    • #253727
      Participant
      Topics: 1
      Replies: 2
      Points: 15
      Rank: Member

      Hi Olaf,

      thx for the code. I edited my post.
      Unfortunately i get an Error 🙁
      Missing Argument for the Parameter “ClassName”

      I tryed to change add the classname CIM_LogicalDisk but then i get an error “Get-CimInstance : The WS-Management service cannot process the request. The WQL query is invalid.”

    • #253730
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      Oooops … my fault … sorry for that …. I changed the code above. Simply use “Win32_LogicalDisk” as the class name.

    • #253739
      Participant
      Topics: 1
      Replies: 2
      Points: 15
      Rank: Member

      aaaaand it´s working.
      Cool 🙂
      Thx Olaf

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