Today I have written some little code that should change my Default Browser.
Here's my code:
function Set-DefaultBrowser
{
$browser = (Get-Item -Path "HKLM:\SOFTWARE\RegisteredApplications").Property | Where-Object -FilterScript{ $ -like "Firefox*"} # Read registered Browsers and Filter Firefox
Invoke-Expression "$($exe_path) HKLM $($browser)"
}
But I'm getting this error:
$ : Die Benennung "$" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die Schreibweise des Namens, oder ob der
Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang.
In N:\Privat\Dokumente\philips_bs_script.ps1:19 Zeichen:112
+ ... steredApplications").Property | Where-Object -FilterScript{ $ -like " ...
+ ~
+ CategoryInfo : ObjectNotFound: ($:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Do you have any solution for this?
Thanks VallingSki
The warning is hinting that "$" is not the name of a cmdlet known by Powershell. In your -FilterScript
scriptblock you've typed "$" when you probably meant to type "$_".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.