Last active
September 4, 2020 13:11
-
-
Save exactmike/5ee916deeae31c9b4db8baf0e56a6844 to your computer and use it in GitHub Desktop.
Powershell Function Development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #From https://www.joseespitia.com/2020/02/07/automatically-create-microsoft-edge-profile-shortcuts/ | |
| $EdgeProfiles = Get-ChildItem "$env:LOCALAPPDATA\Microsoft\Edge\User Data" | Where-Object { $_.Name -like "Profile *" } | |
| ForEach ($EdgeProfile in $EdgeProfiles.Name) | |
| { | |
| # Get Profile Name | |
| $Preferences = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\$EdgeProfile\Preferences" | |
| $Data = (ConvertFrom-Json (Get-Content $Preferences -Raw)) | |
| $ProfileName = $Data.Profile.Name | |
| # Create Shortcut on Desktop | |
| $TargetPath = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" | |
| $ShortcutFile = "$env:USERPROFILE\Desktop\Edge - $ProfileName.lnk" | |
| $WScriptShell = New-Object -ComObject WScript.Shell | |
| $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile) | |
| $Shortcut.IconLocation = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\$EdgeProfile\Edge Profile.ico, 0" | |
| $Shortcut.Arguments = "--profile-directory=""$EdgeProfile""" | |
| $Shortcut.TargetPath = $TargetPath | |
| $Shortcut.Save() | |
| } | |
| # Get Profile Name | |
| $Preferences = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Preferences" | |
| $Data = (ConvertFrom-Json (Get-Content $Preferences -Raw)) | |
| $ProfileName = $Data.Profile.Name | |
| If ($ProfileName -eq "Person 1") | |
| { | |
| $ProfileName = "Default" | |
| } | |
| # Create Shortcut on Desktop | |
| $TargetPath = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" | |
| $ShortcutFile = "$env:USERPROFILE\Desktop\Edge - $ProfileName.lnk" | |
| $WScriptShell = New-Object -ComObject WScript.Shell | |
| $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile) | |
| $Shortcut.IconLocation = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Edge Profile.ico, 0" | |
| $Shortcut.Arguments = "--profile-directory=""Default""" | |
| $Shortcut.TargetPath = $TargetPath | |
| $Shortcut.Save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-ShortDomainNameFromDN | |
| { | |
| param([parameter(Mandatory, ValueFromPipeline)][string]$DistinguishedName) | |
| $DistinguishedName.split(',').where( { $_ -like 'DC=*' }).foreach( { $_.split('=')[1] }) | Select-Object -First 1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment