Forrest logo
back to the Get-Module tool

where-object:tldr:a6647

where-object: Use multiple conditions.
$ Get-Module -ListAvailable | Where-Object { $_.Name -NotLike "Microsoft*" -And $_.Name -NotLike "PS*" }
try on your machine

This command is a PowerShell command that retrieves a list of all available modules on the system and filters out any modules whose names start with "Microsoft" or "PS".

Here is a breakdown of the command:

  1. Get-Module: This cmdlet is used to retrieve a list of all loaded modules or all available modules on the system.
  2. -ListAvailable: This parameter is used to specify that only the available modules should be listed. If this parameter is not provided, it will also include the loaded modules.
  3. | (pipe): This is a pipeline operator that takes the output from the previous command and passes it as input to the next command.
  4. Where-Object: This cmdlet is used to filter the objects that are passed through the pipeline based on a specified condition.
  5. { $_.Name -NotLike "Microsoft*" -And $_.Name -NotLike "PS*" }: This is a script block that represents the condition for filtering the objects. In this case, it checks if the name of the module ($_.Name) does not match the pattern "Microsoft" and does not match the pattern "PS". -NotLike is the comparison operator used for pattern matching, and * is a wildcard character that matches any number of characters.

So, the command essentially retrieves a list of available modules and filters out any modules whose names start with "Microsoft" or "PS". The resulting output will be a list of modules that do not have these patterns in their names.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the Get-Module tool