Advertisement
Combreal

objDumper.ps1

Sep 19th, 2024 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [Console]::OutputEncoding = [System.Text.Encoding]::Default
  2.  
  3. Function Dump-Obj ($obj) {
  4.     $finalOutput = ""
  5.     $output = ""
  6.     $output = $obj | Format-Custom | Out-String
  7.     $output = $output -split "`n"
  8.     Foreach ($line in $output) {
  9.         If ($line.IndexOf('{') -eq -1 -And $line.IndexOf('}') -eq -1 -And $line.IndexOf('[') -eq -1 -And $line.IndexOf(']') -eq -1 -And $line -notlike "*class *" -And $line -notmatch '^\s*$') {
  10.             $finalOutput += $line + "`n"
  11.         }
  12.     }
  13.     $finalOutput = $finalOutput.Trim()
  14.     Return $finalOutput
  15. }
  16.  
  17. $cardGameDocumentation = New-Object -TypeName "PSObject" -Property @{
  18.     'Definition' = "A card game is any game that uses playing cards as the primary device with which the game is played, whether the cards are of a traditional design or specifically created for the game.";
  19.     'Links' = 'https://en.wikipedia.org/wiki/Card_game'
  20. }
  21.  
  22. $murderDocumentation = New-Object -TypeName "PSObject" -Property @{
  23.     'Definition' = "Murder is the unlawful killing of another human without justification or valid excuse committed with the necessary intention as defined by the law in a specific jurisdiction.";
  24.     'Links' = 'https://en.wikipedia.org/wiki/Murder'
  25. }
  26.  
  27. $userInterests = @()
  28. $userInterest = New-Object -TypeName "PSObject" -Property @{
  29.     'Name' = "Card game";
  30.     'Requierement' = 'Good at math';
  31.     'Documentation' = $cardGameDocumentation
  32. }
  33. $userInterests += $userInterest
  34.  
  35. $userInterest = New-Object -TypeName "PSObject" -Property @{
  36.     'Name' = "Murder";
  37.     'Requierement' = 'Cold blood';
  38.     'Documentation' = $murderDocumentation
  39. }
  40. $userInterests += $userInterest
  41.  
  42. $userProfile = New-Object -TypeName "PSObject" -Property @{
  43.     'Name' = "Tony";
  44.     'Surname' = "Montana";
  45.     'Date' = "01/12/1973";
  46.     'Interests' = $userInterests       
  47. }
  48.  
  49. Dump-Obj $userProfile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement