Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Variable declaration
- $FilePath = "C:\Scripts\Credentials\O365TenantName.txt"
- $Username = "YOURADMIN@YOURTENANT.COM"
- # Here you should check if modules are loaded and load them
- # This is just a sample, adapt/change as needed.
- If (!(get-module MSOnline))
- {
- Import-Module MSOnline
- }
- # Import the password to use, decrypt it, then build the credential object.
- $PasswordText = Get-Content -Path $FilePath
- $SecurePassword = $PasswordText | ConvertTo-SecureString
- $CredentialObject = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword
- # Connect to the Office 365 services you will be using.
- Connect-MsolService -Credential $CredentialObject
- # Run your commands
- Get-MsolUser -All
- #If you need to write to log or write the output you should do this here.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement