How to check if PowerShell result contains these words

I’m doing an IF statement in PowerShell and at some point I do this: (Get-BitlockerVolume -MountPoint "C:").KeyProtector.keyprotectortype which gives me the results in this format, on top of each other I want to write my IF statement to check whether the output of the command above contains both "TpmPin" and "RecoveryPassword" but not sure what… Read More How to check if PowerShell result contains these words

$_.Exception is $null when used in a call – why?

I have a PowerShell script containing the following logging function: function LogError([string] $message, $exception = $null) {…} In a try-catch block, when an exception occurs, I call that logging function like this: catch { LogError("…", $_.Exception) } In the LogError function, the second argument is always $null. Why? I couldn’t find any documentation that would… Read More $_.Exception is $null when used in a call – why?

I want to remove certain parts of a certain string in Powershell 7.2.4, how do I do it?

I have the string "url": "https://maven.fabricmc.net/net/fabricmc/fabric-installer/0.11.0/fabric-installer-0.11.0.jar". I want to remove everything from the string except https://maven.fabricmc.net/net/fabricmc/fabric-installer/0.11.0/fabric-installer-0.11.0.jar (I want to remove the quotes as well). How do I go about it? >Solution : $str = """url"": ""https://maven.fabricmc.net/net/fabricmc/fabric-installer/0.11.0/fabric-installer-0.11.0.jar""" $str.Split(""": """)[1].Replace("""","")