Managing SharePoint with PowerShell Core

Since Exchange is managed through a remote session, the commands are simply issued from the PowerShell Core instance but executed on the remote machine (the Office 365 remote connection that we set up with New-PSSession).

The following script is very similar to the connection script in Chapter 5, Managing Exchange Online Using PowerShell. To showcase how we can combine Unix and PowerShell commands, we pipe the results of the Get-User command to a file and then use the cat command to show the contents of the result.txt file on the screen:

Last login: Sat Jul 15 16:34:48 2017 from martinp7.localdomain
[psuser@centos7B ~]$ powershell

PowerShell v6.0.0-beta.4
Copyright (C) Microsoft Corporation. All rights reserved.

PS /home/psuser> $creds = Get-Credential # prompt user for credentials
Windows PowerShell credential request
Enter your credentials.
User: [email protected]
Password for user [email protected]: ****************

PS /home/psuser> $uri = 'https://outlook.office365.com/powershell-liveid/?proxymethod=rps'
PS /home/psuser> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $uri -Credential $creds -Authentication Basic -AllowRedirection
PS /home/psuser> Import-PSSession $Session
WARNING: The names of some imported commands from the module 'tmp_vnlud1wj.ujr' include unapproved verbs that might make them less discoverable. To find the commands with unapproved
verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.

ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0 tmp_vnlud1wj.ujr {Add-AvailabilityAddressSpace...}

PS /home/psuser> Get-User > result.txt
PS /home/psuser> ls
result.txt
PS /home/psuser> cat ./result.txt

Name RecipientType
---- -------------
test1 User
admin1 UserMailbox
test2 UserMailbox
test4 UserMailbox
admin2 UserMailbox
...
PS /home/psuser> Remove-PSSession $Session
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.107.31