0

I don't know if this is a problem on a larger set of Powershell library commands, but I'm using the Share Point Online library right now and can't get this to work:

Get-SPODeletedSite | Select-String "100060-24"

I can see that this string exists in the output if I just type "Get-SPODeletedSite", but when I try and filter for just the line that contains this text, it comes up empty. What's going on here? This is a basic piping operation.

Quark Soup
  • 4,272
  • 3
  • 42
  • 74
  • Per the documentation: "Finds text in strings and files." So if you do a get-member on the output from Get-SPODeletedSite what type of object is returned? – RetiredGeek Feb 24 '21 at 16:48
  • An array of structures, I would imagine. but at some point, these structures are converted to strings in order to show up on the console. – Quark Soup Feb 24 '21 at 19:15
  • But you're not filtering the console display you're filtering the structures. – RetiredGeek Feb 24 '21 at 19:18
  • I don't want to filter the structures. I want to filter the console display. Why is this a difficult operation for Powershell? – Quark Soup Feb 25 '21 at 12:19

1 Answers1

0

PowerShell is an Object-Oriented language. As such, it is designed to work with Objects (Structures). PS has builtin instructions on how to present Objects on the screen but that is for display purposes only. That's the best explanation I can provide. Maybe someone with a better overall understanding of PS could offer a better explaination.

RetiredGeek
  • 2,980
  • 1
  • 7
  • 21
  • Look, as a programmer, I understand the utility of being able to query and manipulate data structures. As a shell programmer, I also understand the utility of being able to grep the output of an operation. There must be some utility in Powershell to convert the structures to greppable output. – Quark Soup Feb 25 '21 at 16:54
  • Additionally, it's not logical that we can pipe the outputs to a file, but not through a filter. – Quark Soup Feb 25 '21 at 17:00
  • Quarkly, see this MS article: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_format.ps1xml?view=powershell-5.1 – RetiredGeek Feb 25 '21 at 23:06