Tag: PowerShell

PS: Connect to Skype Online with MFA / 2FA

PS: Connect to Skype Online with MFA / 2FA

Import-Module LyncOnlineConnector
$sfbSession = New-CsOnlineSession
Import-PSSession $sfbSession
Advertisements
PS: User Mailbox SMTP Alias Address Report

PS: User Mailbox SMTP Alias Address Report

Hi Everyone,

Here is a quick and dirty script that will produce a table within your terminal session showing you each user mailbox along with any additional SMTP addresses that are associated to each of the mailbox’s

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
# Collect Data from exchange and store into varible
$box = Get-Mailbox | Where {$_.name -NotLike ‘*DiscoverySearchMailbox*’} | Where-Object -Property RecipientType -eq -Value UserMailbox | select primarysmtpaddress,name,@{Name=”EmailAddresses”;Expression={ ($_.EmailAddresses | Where-Object {$_ -cmatch “s mtp:*”} | ForEach-Object {$_ -replace 'smtp:' }) -join ',' }}
# Perform Count of records in varible
$count = $box | measure
# Count Output
Write-Host "Result Count: " -NoNewline -ForegroundColor Green $count.Count
# Result Table Output
$box | ft -autosize

 


Old Code

$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session Get-Mailbox | Where {$_.name -NotLike ‘*DiscoverySearchMailbox*’} | Where-Object -Property RecipientType -eq -Value UserMailbox | select primarysmtpaddress,name,@{Name=”EmailAddresses”;Expression={ ($_.EmailAddresses | Where-Object {$_ -cmatch “s mtp:*”} | ForEach-Object {$_ -replace ‘smtp:’ }) -join ‘,’ }} | ft -AutoSize

PowerCLI: Search VM By MAC Address

PowerCLI: Search VM By MAC Address

The below snippet is pretty useful for when you have a mac address conflict between your VM’s. The VMware alarm/flag does not tell you the VM that it MAC conflicts with so time to open up PowerCLI and run the below example

 

Get-VM | Get-NetworkAdapter | Where {$_.MacAddress -eq “00:59:59:c9:da:9a”} | select @{Name="VM";Expression={$_.Parent}},MacAddress | ft -AutoSize

 

PowerCLI: Set VM Tools Time Sync

PowerCLI: Set VM Tools Time Sync

Please see below for the snippet to enable VM time sync with host time via VMware Tools using PowerCLI

$vm = Get-VM -Name "TEST-VM-01"
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.changeVersion = $vm.ExtensionData.Config.ChangeVersion
$spec.tools = New-Object VMware.Vim.ToolsConfigInfo
$spec.tools.syncTimeWithHost = $true
$_this = Get-View -Id $vm.Id
$_this.ReconfigVM_Task($spec)