Closed Grendel04 closed 1 week ago
@Grendel04 - Can you please try with the latest nightly and let us know if this is still the case ? We have improved this part of the code, should help.
@Grendel04 - Can you please try with the latest nightly and let us know if this is still the case ? We have improved this part of the code, should help.
No change with the nightly build. I still need -ClientId to avoid the Warning and the additional Interactive popup.
@Grendel04 - is a valid bug indeed. To save the trouble of changing things in your scripts, you can also specify an environment variable ENTRAID_APP_ID
with the value of your AppId/ClientId.
Like this :
$Env:ENTRAID_APP_ID = "<Client-Id>"
We have modified the code to pick up value from the variable.
https://pnp.github.io/powershell/articles/defaultclientid.html
Will try and fix the bug for sure, keeping this open.
Not sure if this could be called a bug. It has never been built to work this way. I have created a PR https://github.com/pnp/powershell/pull/4425 which mitigates what is being asked for here. Not sure if it makes things better or only less intuitive though. You could also simply pass in -ClientId $AdminConn.ClientId on your second connect, right?
I've implemented both methods in various scripts. Thank you both!
Is your feature request related to a problem? Please describe.
I have scripts that use the following variables $AdminConn = Connect-PnPOnline -Url $adminurl -Interactive -ReturnConnection $SiteConn = Connect-PnPOnline -Connection $AdminConn -Url $site -Interactive -ReturnConnection
I'm changing my scripts to make use of a custom App Reg, so it would be handy to have the variables like this
$AdminConn = Connect-PnPOnline -Url $adminurl -ClientId $clientid -Interactive -ReturnConnection $SiteConn = Connect-PnPOnline -Connection $AdminConn -Url $site -Interactive -ReturnConnection
But this throws "WARNING: Connecting with -Interactive uses the PnP Management Shell....."
This shows me that the ClientId in the $AdminConn is being ignored when using -Connection $AdminConn
Describe the solution you'd like
Make use of the ClientId when using -Connection so -ClientId doesn't need to be used on subsequent connections
Describe alternatives you've considered
The workaround is using the following variables
$AdminConn = Connect-PnPOnline -Url $url -ClientId $clientid -Interactive -ReturnConnection $SiteConn = Connect-PnPOnline -Connection $AdminConn -Url $site -ClientId $clientid -Interactive -ReturnConnection
Additional context
None really, It's not a huge pain to add -ClientId to the various Connections made in my scripts, it just seems unnecessary (Kinda like needing -Interactive when the -Connection uses a context that was already -Interactive...)