Closed p-harrison closed 6 months ago
Although recommended just to avoid issues, it should not be required and we do test without running as administrator. Most often we run across an issue like this when there is an old module that is stuck in the local profile and did not upgrade cleanly.
Thanks for responding @jimbanach. We experience the same thing on all our Windows machines, so I don't think it's a module updating issue. However having spent (lots!) more time investigating it I am certain it is not related to your Compliance script specifically - essentially if we run Connect-ExchangeOnline or Connect-IPPSSession within a PS1 as a non-admin no modules/functions are available to the script even though the connection is successful (as evidenced by the fact that when the script ends you can use all the imported functions). Very odd!
If you happened to be bored and could cast an eye at a TechCommunity post I created about the issue it would be most appreciated :) - https://techcommunity.microsoft.com/t5/windows-powershell/powershell-cmdlets-not-available-within-a-script-unless-it-is/m-p/4122837#M7974. Or even give somebody in the PS team a prod to take a look maybe.
Cheers
Most of our users are not local administrators on their machines and have no access to an admin account. I wonder if it's possible to change the script so it can run as a regular user account? I am not a PowerShell guru by any means, but it does not seem like the script does anything that should truly require local admin privileges?
When running it as a regular user we see the following error -
Strangely if I run Connect-IPPSSession followed by Connect-ExchangeOnline myself the get-dlpcompliancepolicy cmdlet is available.
Thanks for any thoughts!