Archive/Set-Office365Credentials.ps1


function Set-Office365Credentials {

    # version 1

    Param (

        [parameter(mandatory = $true, Position = 0)]
        [ArgumentCompleter( {
                param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters )
                (Get-ChildItem -Path "$([Environment]::GetFolderPath("MyDocuments"))\WindowsPowerShell\pwd\$wordToComplete*" -Directory).Name
            })]
        [string]$Tenant

    )
    #$Tenant = Read-Host -Prompt "Tenant?"

    $PwdFolder = "$([Environment]::GetFolderPath("MyDocuments"))\WindowsPowerShell\pwd\" + $Tenant

    #$OnpremPasswordFile = $PwdFolder + "\Onprempwd.xml"
    $Office365PasswordFile = $PwdFolder + "\Office365pwd.xml"


    #$OnPremCreds = Get-Credential -Message "Enter password for Domain Admin"
    #$OnPremCreds | Export-CliXml -Path $OnpremPasswordFile
    $OfficeCredential = Get-Credential -Message "Enter password for Office365 Admin"

    if (!(Test-Path $PwdFolder)) { New-Item -Path $PwdFolder -Type Directory | Out-Null }

    $OfficeCredential | Export-CliXml -Path $Office365PasswordFile

}