Powershell Ordnername auslesen und verwenden
Hallo an alle,
hoffe ich bin hier richtig und jemand kann mir helfen
Ich möchte eine cert Datei in das Firefox Profil mittel Powershell kopieren. Das FF Profil heißt ja bei jedem Benutzer unterschiedlich, daher wollte ich den Namen erst auslesen und
diesen anschließend für den Copy Job verwenden. Leider funktioniert dies nicht wie gewünscht
Ich habe es mal so versucht.
Script:
Vielen Dank schon mal!!
LG Simon
hoffe ich bin hier richtig und jemand kann mir helfen
Ich möchte eine cert Datei in das Firefox Profil mittel Powershell kopieren. Das FF Profil heißt ja bei jedem Benutzer unterschiedlich, daher wollte ich den Namen erst auslesen und
diesen anschließend für den Copy Job verwenden. Leider funktioniert dies nicht wie gewünscht
Ich habe es mal so versucht.
Script:
$UserAPPDATA = $env:APPDATA
Get-ChildItem $UserAPPDATA\Mozilla\Firefox\Profiles\
$ProfileName = Get-ChildItem $UserAPPDATA\Mozilla\Firefox\Profiles\ | Select-Object Name #Hier gibt es nur einen Ordner. Ansonsten könnte man ja auch noch where-object -eq "*.default" einbauen
Get-ChildItem -recurse "$UserAPPDATA\Mozilla\Firefox\Profiles\$ProfileName" # Weiß nicht ob dies prinzipiell funktioniert?
Copy-Item "c:\cert.db" "$UserAPPDATA\Mozilla\Firefox\Profiles\$ProfileName"
LG Simon
Please also mark the comments that contributed to the solution of the article
Kommentar vom Moderator Dani am Aug 11, 2016 um 10:48:03 Uhr
Formatierung hinzugefügt.
Content-Key: 312362
Url: https://administrator.de/contentid/312362
Printed on: April 20, 2024 at 05:04 o'clock
3 Comments
Latest comment
Moin,
das Verzeichnis bzw. dessen Namen kannst du so auslesen:
Somit kannst du das auch bequem mit dem cmdlet Copy-Item verknüpfen.
Getestet unter Windows 10.
Gruß,
Dani
das Verzeichnis bzw. dessen Namen kannst du so auslesen:
Get-ChildItem "$env:Appdata\Mozilla\Firefox\Profiles\" | Select -ExpandProperty Name
Copy-Item "C:\temp\2593_256.png" "$(Get-ChildItem "$env:Appdata\Mozilla\Firefox\Profiles\" | Select -ExpandProperty FullName)"
Gruß,
Dani
I would rather extract the default profile from the profiles.ini to get the "correct" firefox profile folder for the current user, because this is not necessarily the *.default folder!!
Regards
$ff_profile_folder = "$env:APPDATA\Mozilla\Firefox\$([regex]::match((gc "$env:APPDATA\Mozilla\Firefox\profiles.ini" | out-string),'(?ism)^Path=([^\r\n]+)[^\[]*?Default=1').Groups[1].Value.replace("/","\"))"
$ff_profile_folder
Copy-Item "c:\cert.db" -Destination $ff_profile_folder -Force