Error mapping to Quick Access links

I have a script I use to map Office 365 document libraries and Onedrive to Quick Access links in Windows 10. This has worked well using Internet Explorer. Now that IE is going away I want to do the same with Chrome, but getting errors. Creating a Quick Access link to a o365 document library works, but when I try to do the same for OneDrive it gives and error. Even if I hardcode my name in the $env it still errors out.

Here is what works:

$chrome = Start-Process -WindowStyle Minimized -file chrome.exe -ArgumentList '--new-window', 'https://mycompany.sharepoint.com/sites/Site/DocumentLibrary' -PassThru
$folder = '\\mycompany.sharepoint.com@SSL\DavWWWRoot\sites\Site\DocumentLibrary'
$QuickAccess.Namespace($folder).Self.InvokeVerb("pintohome")

I get an error with this last command:

$chrome = Start-Process -WindowStyle Minimized -file chrome.exe -ArgumentList '--new-window', "https://mycompany-my.sharepoint.com/personal/${env:username}_mycompany_com\Documents" -Passthru 
$folder2 = "\\mycompany-my.sharepoint.com@SSL\DavWWWRoot\personal\${env:username}_mycompany_com\Documents"
$QuickAccess.Namespace($folder2).Self.InvokeVerb("pintohome")

Error: InvalidOperation: You cannot call a method on a null-valued expression.

how about doing like

-ArgumentList "--new-window https://mycompany-my.sharepoint.com/personal/${env:username}_mycompany_com\Documents"

Thanks for the suggestion kvprasoon, but still getting same error.

Does it make any difference if the backslash is changed to a forward slash?

unfortunately still getting error. The first two lines run fine. It’s the last line that gives me the error.

Can you share your code that populates the variable $QuickAccess?

To fix this, we need to work out why $QuickAccess is NULL.

$QuickAccess = New-Object -ComObject shell.application

Ok, so that bit is probably OK.

What’s the output of:

$QuickAccess

$QuickAccess.NameSpace($folder2)

and

$QuickAccess.NameSpace($folder2).Self

What happens it you try:

$QuickAccess.Namespace($folder2)
$QuickAccess.InvokeVerb("pintohome")

output for $QuickAccess

Application Parent


System.__ComObject System.__ComObject

no output from $QuickAccess.NameSpace($folder2)

no output from $QuickAccess.NameSpace($folder2).self

Tonyd,
The first command runs fine. The second throws the error:
InvalidOperation: Method invocation failed because [System.__ComObject] does not contain a method named 'InvokeVerb'.

What happens if you simply use:

$QuickAccess.Namespace($folder2).Self.InvokeVerb()

The default verb is “Open”

I get same error as orignal issue:

InvalidOperation: You cannot call a method on a null-valued expression.

Do you have any other way of validating that the UNC path for $folder2 is correct? e.g. does it open for you in Explorer?

I’m pretty sure that the problem is it doesn’t like that path. I’ve tried several variations with my own OneDrive and I cannot get a working UNC path.

It doesn’t work in Explorer, but this script works fine with IE.

If it’s OK with IE, the only thing I can suggest that might be affecting it is Trusted Sites; because that’s what the error I’m getting relates to when I try to browse to it in Directory Opus. Perhaps Chrome has a similar problem.

PowerShell and File Explorer don’t give any error, they just hang for a while.

image

I have added it to Trusted Sites but no dice.

Matt,
Here is what I have under Trusted Sites:
https://mycompany-files.sharepoint.com
https://mycompany-myfiles.sharepoint.com

Local Intranet:
https://.mycompany.com
https://
.sharepoint.com
https://autologon.microsoftazuread-sso.com

Thanks your help on this.