Combreal

customObjShort2.ps1

May 9th, 2023 (edited)
1,242
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 0.75 KB | Source Code | 0 0
  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8. [PSCustomObject]@{"Computer"="MachineName";"Manufacturer"="Dell Inc.";"Model"="Precision 5530"}
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. #Example
  18.  
  19. $modelList = foreach ($Computer in $Computers) {
  20.     $Result = Invoke-Sqlcmd -ServerInstance $SCCMServer -Database $SCCMDB -Query "SELECT Manufacturer0, Model0 FROM v_GS_COMPUTER_SYSTEM WHERE Name0 = '$Computer'"
  21.     [PSCustomObject]@{"Computer"=$Computer;"Manufacturer"=$Result.Manufacturer0;"Model"=$Result.Model0}
  22. }
  23. $modelList
  24.  
  25.  
  26.  
  27. #$CustomObjs=@()
  28. #
  29. #$CustomObj = New-Object -TypeName PSObject -Property @{ 'Name' = "Tobby"; 'Date' = "12/02/2023" }
  30. #$CustomObjs += $CustomObj
  31. #$CustomObj = New-Object -TypeName PSObject -Property @{ 'Name' = "Kazumi"; 'Date' = "21/07/2023" }
  32. #$CustomObjs += $CustomObj
  33. #
  34. #$CustomObjs
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment