PS (Unfinished): O365 User Exporter For MaaS360

PS (Unfinished): O365 User Exporter For MaaS360

Image result for its broken meme

#############################################
## Global Varibles
#############################################
$script:SelectedPath = $null
$script:PrimaryDomain = $null
$script:PulledUserData = $null
$Script:date = Get-Date -Format ddmmyyhhmm
#############################################
## Functions
#############################################
Function EnvConfiguration () {
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -ErrorAction Stop
Add-Type -AssemblyName PresentationFramework
Add-Type -assemblyName PresentationCore
Add-Type -assemblyName WindowsBase
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
}
Function WelcomeDialouge () {
# Dialouge Box Params
$ButtonType = [Windows.MessageBoxButton]::OKCancel
$MessageIcon = [Windows.MessageBoxImage]::Information
$MessageTitle = "ASB -- O365 CSV Exported For IBM MaaS360 -- Daisy Stevens"
$MessageBody = "Welcome to the O365 Exporter Tool for`nMass User Importation into MaaS360`n `nScript Developed By: Daisy Olivia Stevens`nhttps://adminscriptbank.wordpress.com`nhttps://www.linkedin.com/in/theheroic"
# Dialouge Call
$Result = [Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
if ($Result -eq 'OK'){ConnectO365}
}
Function ConnectO365 (){
# Obtain Creds from User input and then connect to Office 365
Connect-MsolService #-ErrorAction stop
# Move to the next function
Set-DestinationPath
}
function Set-DestinationPath {
$Message = "Please select a directory for your exported data"
$FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{SelectedPath = 'C:\'}
$FolderBrowser.Description = $Message
[void]$FolderBrowser.ShowDialog()
$FolderBrowser.SelectedPath
if ($FolderBrowser.SelectedPath -eq $null){
# Dialouge Box Params
$ButtonType = [Windows.MessageBoxButton]::OKCancel
$MessageIcon = [Windows.MessageBoxImage]::Error
$MessageTitle = "ASB -- O365 CSV Exporter For IBM MaaS360 -- Daisy Stevens"
$MessageBody = "No Path Was Selected!`nDo you wish to try again?"
# Dialouge Call
$Result = [Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
if ($Result -eq 'OK'){Set-DestinationPath} else {exit}
}
$script:SelectedPath = $FolderBrowser.SelectedPath
PrimaryDomainSelector
}
Function PrimaryDomainSelector {
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "ASB -- O365 CSV Exported For IBM MaaS360 -- Daisy Stevens"
$objForm.Size = New-Object System.Drawing.Size(800,200)
$objForm.StartPosition = "CenterScreen"
$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter")
{$x=$objListBox.SelectedItem;$objForm.Close()}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$objForm.Close()}})
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({$x=$objListBox.SelectedItem;$objForm.Close();PullUserData;})
$objForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = "Please Select Your Primary Domain:"
$objForm.Controls.Add($objLabel)
$objListBox = New-Object System.Windows.Forms.ListBox
$objListBox.Location = New-Object System.Drawing.Size(10,40)
$objListBox.Size = New-Object System.Drawing.Size(755,20)
$objListBox.Height = 80
Get-MsolDomain | Select-Object name | ForEach-Object {$_.Name | Add-Content -Path .\o365Domains.tmp}
ForEach($i in (Get-Content .\o365Domains.tmp))
{[void] $objListBox.Items.Add($i)}
$objForm.Controls.Add($objListBox)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
$script:PrimaryDomain = $objListBox.SelectedItem
$FileName = ".\o365Domains.tmp"
if (Test-Path $FileName)
{
Remove-Item $FileName
}
}
function PullUserData {
$script:PulledUserData = Get-MsolUser -All | Select-Object *
ComposeCSV
}
function CustomInputBox([string] $title, [string] $message, [string] $defaultText) {
[void] [Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$userForm = New-Object System.Windows.Forms.Form
$userForm.Text = "$title"
$userForm.Size = New-Object System.Drawing.Size(800,200)
$userForm.StartPosition = "CenterScreen"
$userForm.AutoSize = $False
$userForm.MinimizeBox = $False
$userForm.MaximizeBox = $False
$userForm.SizeGripStyle= "Hide"
$userForm.WindowState = "Normal"
$userForm.FormBorderStyle="Fixed3D"
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(115,80)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({$value=$objTextBox.Text;$userForm.Close()})
$userForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(195,80)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({$userForm.Close()})
$userForm.Controls.Add($CancelButton)
$userLabel = New-Object System.Windows.Forms.Label
$userLabel.Location = New-Object System.Drawing.Size(10,20)
$userLabel.Size = New-Object System.Drawing.Size(280,20)
$userLabel.Text = "$message"
$userForm.Controls.Add($userLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,40)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objTextBox.Text="$defaultText"
$userForm.Controls.Add($objTextBox)
$userForm.Topmost = $True
$userForm.Opacity = 1.0
$userForm.ShowIcon = $False
$userForm.Add_Shown({$userForm.Activate()})
[void] $userForm.ShowDialog()
$value=$objTextBox.Text
return $value
}
function ComposeCSV {
$UserInputTitle = "ASB -- O365 CSV Exporter For IBM MaaS360 -- Daisy Stevens"
$userInputText = "Please enter your international country code: "
$UserInputDText = "+44"
$userInput = CustomInputBox $UserInputTitle $userInputText $UserInputDText
if ($userInput -eq $null){
$userInput = CustomInputBox $UserInputTitle $userInputText $UserInputDText
}
$Data = New-Object System.Object
$Data | Add-Member -MemberType Property -Name "Full Name" -Value $script:PulledUserData.DisplayName
$Data | Add-member -MemberType Property -Name "User Name" -Value $script:PulledUserData.Signinname
$Data | Add-Member -MemberType Property -Name "Domain" -Value $Domain
$Data | Add-Member -MemberType Property -Name "Email" -Value $script:PulledUserData.signinname
$Data | Add-Member -MemberType Property -Name "Phone Number Country" -Value $userInput
$Data | Add-Member -MemberType Property -Name "Phone Number" -Value $script:PulledUserData.PhoneNumber
$Data | Add-Member -MemberType Property
-Name "Location" -Value "London"
$Data | add-member -MemberType Property -Name "Auth Type" -Value "Local"
$Data | select * | Export-Csv -Path "$script:SelectedPath\Maas360_Export_$script:date.csv" -NoTypeInformation
CompleteMSG
}
function CompleteMSG {
# Dialouge Box Params
$ButtonType = [Windows.MessageBoxButton]::OK
$MessageIcon = [Windows.MessageBoxImage]::Information
$MessageTitle = "ASB -- O365 CSV Exported For IBM MaaS360 -- Daisy Stevens"
$MessageBody = "The Script has completed successfully"
# Dialouge Call
$Result = [Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
if ($Result -eq 'OK'){exit}
}
#############################################
## Function Calls
#############################################
EnvConfiguration
WelcomeDialouge
Advertisements
PS: Enable MFA For All Users O365

PS: Enable MFA For All Users O365

The below script will instruct your PowerShell session to connect to your Office365 environment and enable MFA across all enabled accounts within your estate

# Configuration of Powershell Session
Set-ExecutionPolicy Unrestricted –Scope CurrentUser
# Importation of Modules
Import-Module MSOnline
# User Input for O365 Creds
$UserCredential = Get-Credential
# Powershell Connection Standup with O365
Connect-MsolService –Credential $UserCredential
# Configuration of MFA Enviromental Varibles
$auth = New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationRequirement
$auth.RelyingParty = "*"
$auth.State = "Enabled"
$auth.RememberDevicesNotIssuedBefore = (Get-Date)
# Apply MFA to all users
Get-MsolUser -EnabledFilter EnabledOnly -All | Foreach{ Set-MsolUser -UserPrincipalName $_.UserPrincipalName -StrongAuthenticationRequirements $auth}
PS: Skype For Business Voice User Set CLI

PS: Skype For Business Voice User Set CLI

The following snippet will commit for the following steps within you Skype for business online environment

  • Open Powershell S4B Session
  • Create a new CLI Policy to withhold CLI
  • Assign new CLI policy to test user
# Connect to Skype For Business Online / Lync Online
Import-Module LyncOnlineConnector
$sfbSession = New-CsOnlineSession
Import-PSSession $sfbSession
# Add CLI Policy
New-CsCallingLineIdentity -Identity Anonymous -Description "anonymous policy" -CallingIDSubstitute Anonymous -EnableUserOverride $false
# Assign CLI Policy
Grant-CsCallingLineIdentity -Identity "Example@Example.com" -PolicyName Anonymous