locked
get descprion value RRS feed

  • Question

  • Hi,

    im trying to find VMs with no descrption in the descrption field and then get the descprition from these vms from AD and then set the variable. Something with -eq null not working.

    $VMs = Get-SCVirtualMachine  | Select-Object Name, ComputerName, Description
    
    foreach ($VM in $VMs)
    {
    
    if ($VM.Description  -eq $null)
    {
    Write-Host $VM.ComputerName 
    Set-SCVirtualMachine -Description | Get-ADComputer -Identity $VM | Select-Object Descrption
    }
    
    }

    Monday, May 18, 2020 8:33 PM

Answers

  • Get-SCVirtualMachine  | 
        Where-Object{ -Not $_.Description } |
        Set-SCVirtualMachine -Description ((Get-ADComputer -Identity $_.Name).Descrption)
    
    


    \_(ツ)_/

    • Proposed as answer by Vector BCO Monday, May 18, 2020 9:17 PM
    • Marked as answer by ITinNeed Tuesday, June 2, 2020 5:53 AM
    Monday, May 18, 2020 8:44 PM

All replies

  • Get-SCVirtualMachine  | 
        Where-Object{ -Not $_.Description } |
        Set-SCVirtualMachine -Description ((Get-ADComputer -Identity $_.Name).Descrption)
    
    


    \_(ツ)_/

    • Proposed as answer by Vector BCO Monday, May 18, 2020 9:17 PM
    • Marked as answer by ITinNeed Tuesday, June 2, 2020 5:53 AM
    Monday, May 18, 2020 8:44 PM
  • thank you for your repley jrv.

    the idea behind me using a variable is that i wanted to get the get-scvirtualmachine into a list |export-csv and then edit the list and then read the list using the foreach loop.

    Monday, May 18, 2020 9:34 PM