New-Alias gwmi Get-CIMInstance -Force New-Alias swmi Set-CIMInstance -Force
:) From: Andrew Craig Sent: 26 July 2016 10:10 To: 'mssms@lists.myitforum.com' <mssms@lists.myitforum.com> Subject: RE: Piping from GWMI to SWMI gwmi is Get-WMIObject not Get-WMIInstance. And then gwmi was superseded in 3.0 by Get-CIMInstance which I completely missed swmi is also replaced anyway in 3.0 by CIMInstance cmdlets. So, what about Get-CIMInstance | Set-CIMInstance?? That should work for you, these are definitely pipeline aware. From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> [mailto:listsad...@lists.myitforum.com] On Behalf Of Andreas Hammarskjöld Sent: 26 July 2016 08:45 To: mssms@lists.myitforum.com<mailto:mssms@lists.myitforum.com> Subject: [mssms] RE: Piping from GWMI to SWMI People... PS C:\> swmi cmdlet Set-WmiInstance at command pipeline position 1 Supply values for the following parameters: Class: PS C:\> Ok, so gwmi is.... Guess what. Get-WMIInstance. Just us flatpack IKEA swedes using short commands... The problem is not that I can't pipe to SWMI, that part works fine. But I don't seem to be able to access properties directly. I guess it's down to PS funniness. So this doesn't work, get the object name instead: PS C:\> $locs = gwmi -namespace root\StifleR -Query "Select * from Subnets" ; foreach ($loc in $locs) { $bepa = "Location with $loc.subnetID" ; swmi -path $loc.path -Arguments @{LocationName=$bepa}} But this does: PS C:\> $locs = gwmi -namespace root\StifleR -Query "Select * from Subnets" ; foreach ($loc in $locs) { $bepa = $loc.subnetID ; $bepa = "Location with ip $bepa" ; swmi -path $loc.path -Arguments @{LocationName=$bepa}} But was really hoping for, but this just returnes null: gwmi -namespace root\StifleR -Query "Select * from Subnets" | swmi -path $loc.path -Arguments @{LocationName="Location with ip $_.subnetID"} //A From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> [mailto:listsad...@lists.myitforum.com] On Behalf Of Michael Niehaus Sent: den 26 juli 2016 07:58 To: mssms@lists.myitforum.com<mailto:mssms@lists.myitforum.com> Subject: [mssms] RE: Piping from GWMI to SWMI Can you use Get-WMIInstance and Set-WMIInstance? Set-WMIInstance indicates that it can take a management object from the pipeline. Thanks, -Michael From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> [mailto:listsad...@lists.myitforum.com] On Behalf Of Andrew Craig Sent: Monday, July 25, 2016 12:50 PM To: mssms@lists.myitforum.com<mailto:mssms@lists.myitforum.com> Subject: [mssms] RE: Piping from GWMI to SWMI SWMI does not accept pipeline input At least that is my understanding. From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> [mailto:listsad...@lists.myitforum.com] On Behalf Of Andreas Hammarskjöld Sent: 25 July 2016 20:54 To: mssms@lists.myitforum.com<mailto:mssms@lists.myitforum.com> Subject: [mssms] Piping from GWMI to SWMI So in PowerShell, when piping from GWMI to SWMI can I access properties from the GWMI object like with $_.? Example of what I am trying to do: GWMI -query "select * from stuff" | SWMI @{Value= $_.Value + 10} Or is that not possible, obviously not working for me... Regards, Andreas Hammarskjöld Co-Founder & Dev Guy Skunkworks Division 2Pint Software<https://2pintsoftware.com/> Mobile: +46 727 253995 andr...@2pintsoftware.com<mailto:andr...@2pintsoftware.com> https://twitter.com/AndHammarskjold