Very odd issue as i have no idea why i can't call any of the functions as per the below.
CLS#… Present the Menu Options
Write-Host “`n`tOffice 365 Connection`n” -ForegroundColor Red
Write-Host “`t`1. Connect To O365” -Fore Cyan
Write-Host “`t`2. Grant Full Access” -Fore Cyan
Write-Host “`t`3. Quit`n” -Fore Yellow
#… Retrieve the response from the user
$option = read-host "Type your choice"
IF ($option -eq 1){LoadMain}
Elseif ($option -eq 2){FullAccess}
Elseif ($option -eq 3){GetLost}
function LoadMain{
CLS
$user = “test@test.OnMicrosoft.com”
$cred = Get-Credential -Credential $user
Import-Module MSOnline
$O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $O365Session -AllowClobber
Connect-MsolService –Credential $cred
clear-host
write-host
write-host -ForegroundColor white "You are now connected to office 365 Shell"
Write-Host
write-host -ForegroundColor white "Get-MsolUser -UserPrincipalName test@test.onmicrosoft.com | FL".
}
function FullAccess{
CLS
$adminaccount = Read-Host "Enter your full email address to provide access to"
$victimaccount = Read-Host "Enter full email address for the account you want access to"
$user = “test@test.OnMicrosoft.com”
$cred = Get-Credential -Credential $user
Import-Module MSOnline
$O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $O365Session -AllowClobber
Connect-MsolService –Credential $cred
Clear-Host
Add-MailboxPermission -Identity $victimaccount -User $adminaccount -AccessRights FullAccess
}
function GetLost{Exit}