Set O365 User Password to Never Expire

Set-ExecutionPolicy RemoteSigned
$cred = Get-Credential
Connect-MsolService -Credential $cred
Set-MsolUser -UserPrincipalName username@domain.com -PasswordNeverExpires $true

Advertisements

Powershell – Send Mail through O365

$cred = Get-Credential
$to = "somebody@domain.com"
$from = "me@domain.com"
$smtp = "smtp.office365.com"
$port = "587"
$body = "<p>This can be <bold>HTML formatted</bold> with a bit of creative tagging.</p>"
$subject = "Look! I can send mail from Powershell"
Send-MailMessage -SmtpServer $smtp -Port $port -UseSsl -Credential $cred -From $from -To $to -Subject $subject -Body $body -BodyAsHtml -Verbose

O365 Skype for Business – Import 3rd Party Conference Credentials

Connect to O365

$cred = Get-Credential
$session = NewCsOnlineSession -Credential $cred -Verbose
Import-PSSession $session

Next, assign the CSV containing the user list to a variable

$accts = Import-Csv "C:\temp\users.csv"

Loop through the accounts in the CSV file and assign the credentials to the users


foreach ($user in $accts) { Set-CsUserAcp -Identity $user.Acct -TollNumber $user.TollNumber -TollFreeNumbers $user.TollFreeNumber -ParticipantPasscode $user.Passcode -Domain "lync.pgi.com" -Name "PGi" -URL "http://www.pgi.com/lynconline/localnums.php" }

If you do not know your Domain or URL, compare with an existing assignment

$user = Get-CsUserAcp
$user.AcpInfo

Remove/Add Rights to Shared O365 Mailbox

Full access rights

Add-MailboxPermission -Identity shared@domain.com -User user@domain.com -AccessRights FullAccess -InheritanceType All
Remove-MailboxPermission -Identity shared@domain.com -User user@domain.com -AccessRights FullAccess -IneritanceType All

Send As

Add-RecipientPermission -Identity shared@domain.com -AccessRights SendAs -Trustee user@domain.com
Remove-MailboxPermission -Identity shared@domain.com -AcccessRights SendAs -Trustee user@domain.com

Send on Behalf


Set-Mailbox -Identity shared@domain.com -GrantSendOnBehalfTo @{remove="user@domain.com"}
Set-Mailbox -Identity shared@domain.com -GrantSendOnBehalfTo @{add="user@domain.com"}

Function to add all permissions for User to Shared Mailbox

function addperms ($sharedmb, $user)
{
Add-MailboxPermission -Identity $sharedmb -User $user -AccessRights FullAccess -InheritanceType All
Add-RecipientPermission -Identity $sharedmb -AccessRights SendAs -Trustee $user
Set-Mailbox -Identity $sharedmb -GrantSendOnBehalfTo @{add="$user"}}

Function to remove all permissions for User to Shared Mailbox

function remperms ($sharedmb, $user)
{
Remove-MailboxPermission -Identity $sharedmb -User $user -AccessRights FullAccess -InheritanceType All
Remove-RecipientPermission -Identity $sharedmb -AccessRights SendAs -Trustee $user
Set-Mailbox -Identity $sharedmb -GrantSendOnBehalfTo @{remove="$user"}}

Remove/Add Email Address O365

Connect to O365 Exchange Online

Then confirm that the user doesn’t already have the email address

Get-Mailbox user_alias@domain.com



Set-Mailbox user@domain.com -EmailAddresses @{add="user_alias@domain.com"}


Review the assigned addresses



$userAcc = Get-Mailbox user@domain.com


$userAcc.EmailAddresses | fl

To remove an address


Set-Mailbox user@domain.com -EmailAddresses @{remove="user_alias@domain.com"}