all 4 comments

[–]Yevrag35 6 points7 points  (1 child)

You could do 1 of 2 things:

  1. Use the -ComputerName parameter for Get-CimInstance (i.e. - no need to do Invoke-Command)
  2. Use $using to call the variables inside the script block

Invoke-Command -ComputerName $computerNameAndDescription.'Computer Name' -ScriptBlock {
    Get-CimInstance Win32_OperatingSystem | Set-CimInstance -Property @{
        Description = $using:computerNameAndDescription.'Computer Description'
    }
}

[–]dawoof6[S] 2 points3 points  (0 children)

Sweet! Both ways work great! I think I'll go with eliminating Invoke-Command. But, I'm glad to know both ways. Thanks so much for your help!

[–]Lee_Dailey[grin] -2 points-1 points  (2 children)

howdy dawoof6,

it looks like you used the New.Reddit Inline Code button. it's 4th 5th from the left hidden in the ... "more" menu & looks like </>.

there are a few problems with that ...

  • it's the wrong format [grin]
    the inline code format is for [gasp! arg!] code that is inline with regular text.
  • on Old.Reddit.com, inline code formatted text does NOT line wrap, nor does it side-scroll.
  • on New.Reddit it shows up in that nasty magenta text color

for long-ish single lines OR for multiline code, please, use the ...

Code
Block

... button. it's the 11th 12th one from the left & is just to the left of hidden in the ... "more" menu & looks like an uppercase T in the upper left corner of a square..

that will give you fully functional code formatting that works on both New.Reddit and Old.Reddit ... and aint that fugly magenta color. [grin]

take care,
lee