Please help me understand something.
I have this simple code:
If i use Get-User or Get-MailboxUser does not matter, the error is the same.
function adb_temp(){ $365master = $cred = get_local_credential New-O365ExchangeSession $365master # call the office365 remote connection function $users = Get-User -ResultSize 1000 }
When i run this i get this error:
Get-User : The term 'Get-User' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
If i just run the code inside the function so just highlight it and run it, it works fine.
I can not find out what is wrong. In both cases the Exchange session is set up correctly.
I have a function that does this:
Function New-O365ExchangeSession() { #close any old remote session Get-PSSession | Remove-PSSession -Confirm:$false #start a new office 365 remote session $cred = get_local_credential $ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication "Basic" -AllowRedirection #Import-PSSession $ExchangeSession $office365 = Import-PSSession $ExchangeSession -AllowClobber -DisableNameChecking write-host "Exchange Session is connected and Imported" }
Is the function doing something else with my session or what?