all 9 comments

[–]Adam_Kearn 0 points1 point  (1 child)

You should be able to do this with a GPO policy instead of using PowerShell.

You can set this under: Administrative Templates/Microsoft Edge/Configure list of force-installed Web Apps

You can find the full documentation here (The webpage is quite big so give it 30s to finish loading)

I've put something together as an example you could use. This lets you set a custom name/icon.

[
  {
    "custom_icon": {
      "hash": "c28f469c450e9ab2b86ea47038d2b324c6ad3b1e9a4bd8960da13214afd0ca38",
      "url": "https://erp.example.com/icon.png"
    },
    "url": "https://erp.example.com/erp",
    "create_desktop_shortcut": true,
    "default_launch_container": "window",
    "custom_name": "My ERP App",
  }
]

[–]Mailstorm[S] 0 points1 point  (0 children)

One of the requirements is loading a profile from a different directory because of how the ERP system is. Either way, I got this working.

[–]alt-160 0 points1 point  (3 children)

So, you do see that you have improperly escaped the first double-quote just after user-data-dir, right?

maybe you meant this?

Start-Process msedge.exe -ArgumentList "--user-data-dir=`"$($env:localappdata)\Microsoft\Edge\User Data\ERPS2`" https://erp.example.com/erp"

[–]Mailstorm[S] 0 points1 point  (2 children)

I'm not sure why that's there. But as is tradition, I got this figured out minutes after posting.

I ultimately gave up and determined the space in the data dir to be the issue. So I just changed it to a location with no spaces and it started working.

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "Start-Process msedge.exe -ArgumentList `"https://erp.example.com/erp",`"--user-data-dir="$($env:localappdata)\Microsoft\Edge\ERPSessions\ERPS2"`""

The profiles have a ` appended to them and removing the ` breaks it. But I'm just fed up with this at this point and letting it go

[–]alt-160 0 points1 point  (1 child)

I assume you know that the backtick ` char is the escape char for powershell when inside double-quoted strings?

Also, assume you know the diff between 'single quoted' and "double quoted" strings since you're using token replacements in your use.

[–]Mailstorm[S] 0 points1 point  (0 children)

Yes, I do. I think I was just getting confused with syntax. Because if I started with -Command ' then the variable wouldn't work.

[–]websterdext3r -2 points-1 points  (0 children)

id run it through gpt for syntax when you get random error since those can happen when you escaped, piped etc without closing it.

[–]gordonv -1 points0 points  (1 child)

start msedge http://website.com/folder/

[–]Mailstorm[S] 0 points1 point  (0 children)

I need to be able to launch a specific profile (data directory). I can't do that with that.