![Forrest logo](/images/logo.png)
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:
Get-Module
: This cmdlet is used to retrieve a list of all loaded modules or all available modules on the system.-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.|
(pipe): This is a pipeline operator that takes the output from the previous command and passes it as input to the next command.Where-Object
: This cmdlet is used to filter the objects that are passed through the pipeline based on a specified condition.{ $_.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.