Start-PowerShell mode on your life

Early in the 80’s there was a T.V. show named MacGyver, where a man with a lots of imagination, and a simplest tools were able to resolve the more complex puzzles and situations.. regards to @RichardDeanAnderson whose played on this show.

Mcgyver

by those days, i was going to school.. and of shore i was in the elementary, but my grandpa, came from N.Y. carrying with him an IBM XT8088, this one was my first PC, was a christmas present, but that was awesome, because by that days, the color displays were pretty rare.

My PC, had as i remember (i was 9 yrs old…) D.O.S as operating system, it also had a 5 1/4 floppy disk, where i remembered to play my first video games, as Prince of persia in a CGA 16 colors monitor, and the clasic of every cars game Test-Drive, also i remember that i had play a brutal chess, and a kind of story telled game, where you made some choices and the game final was diferent each time.

CGA: la historia del modo gráfico que con cuatro colores conquistó al mundo

*thanks to xataka for this image.

In that time i became good with D.O.S., i remember i became passionate because the video-games motivated this, and i started to read the phisical manuals that become with the computer (in that days the internet wasn’t available yet).

Today, with PowerShell, the people can read the manuals of every CMD-LET they want to use, simply typing Get-Help theName-ofCmdLet -Full, even if they know how it works, and want to make use of a CMD-LET, Get-Help theName-ofCmdLet -Examples will show a set of examples with the explanation of that CMD-LET.

What happen if i was a D.O.S user? what if i became from Linux Bash? well, Microsoft has provided a set of alias for commands, and also there is a kind of back compatibility with those old commands from D.O.S, you can get a list of the alias usin Get-Alias  or you can use classic commands as IPCONFIG or DISKPART.

remember, you can list your CMD-LETS using a GET-COMMAND by default PowerShell got more than 900 CMD-LETS, and the old D.O.S just had around of 80 commands.

come with me… touch the keyboard, feel the experience to talk to your computer with these PowerShell, you can be scared, but i say, don’t be shy.

Every Microsoft technology, involves PowerShell as the basis. even many things that you can do with a GUI, you can drive it by PowerShell and more detailed.

certpaths

In this New certification path you can see that every Microsoft Certification Exam, that Exams that prove that you “Know enough” about a product, has a deep drive in PowerShell and most of them have questions related with PowerShell CMD-LETS.

Became a Hero, Became the PowerShell-Man, and you can learn the most for every product.

PSMAN

Anuncios

Administrando AzureAD con PowerShell

En ocasión del nuevo Microsoft Day 2 #SuperLigaDeConocimiento que tendremos en IT Talent calle 72 Bogota, el próximo sábado 26 de Agosto, quiero invitarlos a mi nueva charla de administración desde PowerShell utilizando el modulo de MSOnline, con el cual podemos generar las cuentas de usuarios, los grupos, administrar las licencias, gestionar las contraseñas,  habilitar la sincronizacion de directorio activo onpremise.

Este evento es gratuito, pero les recomiendo el registro previo. los esperamos a todos.

Con Azure-CLI desde Linux administra tu tenant de Azure

En estos días de inquietud mental, me puse a aprender como usar el Azure-CLI (command Line Interface).

Iniciamos conectándonos a Azure con AZ login, Seleccionamos la suscripción con AZ Account, con AZ interactive iniciamos una sesión interactiva, que nos autocompleta los comandos.

sysadmin@SURFACE:~$ sudo -i

[sudo] password for sysadmin:

root@SURFACE:~# az login

To sign in, use a web browser to open the page https://aka.ms/devicelogin and enter the code FBSYDWX to authenticate.

[

{

“cloudName”: “AzureCloud”,

“id”: “6017ae4e-e175-4795-9265-0a75dded652”,

“isDefault”: true,

“name”: “Pay-As-You-Go Dev/Test”,

“state”: “Enabled”,

“tenantId”: “ffb3db32-9dfc-4eae-b841-a4f906b8449”,

“user”: {

“name”: “fcamp@hotmail.com”,

“type”: “user”

}

},

{

“cloudName”: “AzureCloud”,

“id”: “837632d5-0ee5-468e-aea1-d429f927a73”,

“isDefault”: false,

“name”: “Plataformas de MSDN”,

“state”: “Enabled”,

“tenantId”: “f35a6d11-e1f6-485b-aedf-cb6735dc8e6”,

“user”: {

“name”: “fcamp@hotmail.com”,

“type”: “user”

}

}

]

root@SURFACE:~# az –help

 

For version info, use ‘az –version’

 

Group

az

 

Subgroups:

account : Manage subscriptions.

acr : Manage Azure Container Registries.

acs : Manage Azure Container Services.

ad : Synchronize on-premises directories and manage Azure Active Directory

resources.

appservice : Manage your App Service plans.

batch : Manage Azure Batch.

billing : Manage Azure Billing.

cdn : Manage Azure Content Delivery Networks (CDN).

cloud : Manage the registered Azure clouds.

cognitiveservices: Manage Cognitive Services accounts in Azure Resource Manager.

component : Manage and update Azure CLI 2.0 components.

consumption : Manage Azure Consumption.

cosmosdb : Manage Azure Cosmos DB database accounts.

disk : Manage Azure Managed Disks.

dla : Commands to manage Data Lake Analytics accounts, jobs, and catalogs.

dls : Commands to manage Data Lake Store accounts, and filesystems.

feature : Manage resource provider features, such as previews.

functionapp : Manage your function app.

group : Manage resource groups and template deployments.

image : Manage custom Virtual Machine Images.

iot : Connect, monitor, and control millions of IoT assets.

keyvault : Safeguard and maintain control of keys, secrets, and certificates.

lab : Commands to manage DevTest Labs.

lock : Manage Azure locks.

managedapp : Manage template solutions provided and maintained by the ISV using managedapp

and managedapp definitions.

monitor : Commands to manage Azure Monitor service.

mysql : Commands to manage Azure Database for MySQL servers.

network : Manages Azure Network resources.

policy : Manage resource policies.

postgres : Commands to manage Azure Database for PostgreSQL servers.

provider : Manage resource providers.

redis : Access to a secure, dedicated cache for your Azure applications.

resource : Manage Azure resources.

role : Use role assignments to manage access to your Azure resources.

sf : Manage and administer a Service Fabric cluster.

snapshot : Manage point-in-time copies of managed disks, native blobs, or other

snapshots.

sql : Manage Azure SQL Databases and Data Warehouses.

storage : Durable, highly available, and massively scalable cloud storage.

tag : Manage resource tags.

vm : Provision Linux or Windows virtual machines in seconds.

vmss : Create highly available, auto-scalable Linux or Windows virtual machines.

webapp : Manage web apps.

 

Commands:

configure : Configure Azure CLI 2.0 or view your configuration. The command is

interactive, so just type `az configure` and respond to the prompts.

feedback : Loving or hating the CLI? Let us know!

find : Find Azure CLI commands based on a given query.

interactive : Start the interactive experience.

login : Log in to access Azure subscriptions.

logout : Log out to remove access to Azure subscriptions.

 

root@SURFACE:~# az interactive

When in doubt, ask for ‘help’

 

Do you agree to sending telemetry (yes/no)? Default answer is yes: yes

az>> az account list

[

{

“cloudName”: “AzureCloud”,

“id”: “6017ae4e-e175-4795-9265-0a77dded652”,

“isDefault”: true,

“name”: “Pay-As-You-Go Dev/Test”,

“state”: “Enabled”,

“tenantId”: “ffb3db32-9dfc-4eae-b841-a4f90b8c449”,

“user”: {

“name”: “fcamp@hotmail.com”,

“type”: “user”

}

},

{

“cloudName”: “AzureCloud”,

“id”: “837632d5-0ee5-468e-aea1-d4290f27a73”,

“isDefault”: false,

“name”: “Plataformas de MSDN”,

“state”: “Enabled”,

“tenantId”: “f35a6d11-e1f6-485b-aedf-cb675dcc8e6”,

“user”: {

“name”: “fcamp@hotmail.com”,

“type”: “user”

}

}

]

az>> az account set –subscription “Plataformas de MSDN”

az>> az group create –name myazurelab001 –location eastus2

{

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d420f927a73/resourceGroups/myazurelab001”,

“location”: “eastus2”,

“managedBy”: null,

“name”: “myazurelab001”,

“properties”: {

“provisioningState”: “Succeeded”

},

“tags”: null

}

urelab001 –location eastus2 –address-prefixes 10.100.0.0/24 –subnet-name snet001 –subnet-prefix 10.100.0.0/27

{

“newVNet”: {

“addressSpace”: {

“addressPrefixes”: [

“10.100.0.0/24”

]

},

“dhcpOptions”: {

“dnsServers”: []

},

“etag”: “W/\”0e02916a-34f2-45e0-a2f3-89e82fca8ba3\””,

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d429f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/virtualNetworks/vnet001”,

“location”: “eastus2”,

“name”: “vnet001”,

“provisioningState”: “Succeeded”,

“resourceGroup”: “myazurelab001”,

“resourceGuid”: “71d144cc-73d5-4a06-a276-b40b55807fc”,

“subnets”: [

{

“addressPrefix”: “10.100.0.0/27”,

“etag”: “W/\”0e02916a-34f2-45e0-a2f3-89e82fca8ba3\””,

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/virtualNetworks/vnet001/subnets/snet001”,

“ipConfigurations”: null,

“name”: “snet001”,

“networkSecurityGroup”: null,

“provisioningState”: “Succeeded”,

“resourceGroup”: “myazurelab001”,

“resourceNavigationLinks”: null,

“routeTable”: null

}

],

“tags”: {},

“type”: “Microsoft.Network/virtualNetworks”,

“virtualNetworkPeerings”: []

}

}

create –name storage001 –resource-group myazurelab001 –location eastus2 –sku Standard_LRS –kind BlobStorage

The storage account named storage001 is already taken.

unt create –name storage00100 –resource-group myazurelab001 –location eastus2 –sku Standard_LRS –kind BlobStorag

The storage account property ‘accessTier’ is invalid or cannot be set at this time.

rage00100 –resource-group myazurelab001 –location eastus2 –sku Standard_LRS –kind BlobStorage –access-tier Cool

{

“accessTier”: “Cool”,

“creationTime”: “2017-07-26T19:48:54.399653+00:00”,

“customDomain”: null,

“encryption”: null,

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Storage/storageAccounts/storage00100”,

“kind”: “BlobStorage”,

“lastGeoFailoverTime”: null,

“location”: “eastus2”,

“name”: “storage00100”,

“primaryEndpoints”: {

“blob”: “https://storage00100.blob.core.windows.net/“,

“file”: null,

“queue”: null,

“table”: “https://storage00100.table.core.windows.net/

},

“primaryLocation”: “eastus2”,

“provisioningState”: “Succeeded”,

“resourceGroup”: “myazurelab001”,

“secondaryEndpoints”: null,

“secondaryLocation”: null,

“sku”: {

“name”: “Standard_LRS”,

“tier”: “Standard”

},

“statusOfPrimary”: “available”,

“statusOfSecondary”: null,

“tags”: {},

“type”: “Microsoft.Storage/storageAccounts”

}

az>> az ad app list

[

{

“appId”: “15e431d4-7ab0-4f8d-a3c8-afd0bd271aca”,

“appPermissions”: null,

“availableToOtherTenants”: false,

“displayName”: “heraclito_yMJkalX/21DJERDukzmq5XZ6yshUhyHTZsEDIrqe6m4=”,

“homepage”: “https://management.azure.com//subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourcegroups/rg_campohenriquez/providers/Microsoft.Automation/automationAccounts/heraclito“,

“identifierUris”: [

https://spn/yMJkalX%2f21DJERDukzmq5XZ6yshUhyHTZsEDIrqe6m4%3d

],

“objectId”: “cfadc5e8-e497-43c7-8807-4b636e668cb1”,

“objectType”: “Application”,

“replyUrls”: []

}

]

az>> az ad app delete –id 15e431d4-7ab0-4f8d-a3c8-afd0bd271aca

az>> az ad app list

[]

az>> az ad user list

[

{

“displayName”: “Fabian Alberto Camp Henriquez”,

“mail”: null,

“mailNickname”: “fcamp_hotmail.com#EXT#”,

“objectId”: “d6877962-a794-454d-bd2f-cc5a4a7dc1ed”,

“objectType”: “User”,

“signInName”: null,

“userPrincipalName”: “fcamp_hotmail.com#EXT#@salondelmal.onmicrosoft.com”

},

{

“displayName”: “Luis Ronderos”,

“mail”: null,

“mailNickname”: “Luis.Ronderos”,

“objectId”: “d284a888-db3f-4e23-a733-4c65090d5d7f”,

“objectType”: “User”,

“signInName”: null,

“userPrincipalName”: “Luis.Ronderos@salondelmal.onmicrosoft.com”

}

]

az>> az ad user delete –upn-or-object-id luis.ronderos@salondelmal.onmicrosoft.com

az>> az ad user list

[

{

“displayName”: “Fabian Alberto Camp Henriquez”,

“mail”: null,

“mailNickname”: “fcamp_hotmail.com#EXT#”,

“objectId”: “d6877962-a794-454d-bd2f-cc5a4a7dc1ed”,

“objectType”: “User”,

“signInName”: null,

“userPrincipalName”: “fcamp_hotmail.com#EXT#@salondelmal.onmicrosoft.com”

}

]

az>> az vmss create –name lililabdc -g myazurelab001 -l eastus2 –image Win2012R2Datacenter –admin-username liliana –admin-password C0l0mbia2o17$ –vnet-name vnet001 –subnet snet001

{

“vmss”: {

“overprovision”: true,

“provisioningState”: “Succeeded”,

“singlePlacementGroup”: true,

“uniqueId”: “d3e3205d-4028-4cd1-b6f7-95e6ab30686d”,

“upgradePolicy”: {

“mode”: “Manual”

},

“virtualMachineProfile”: {

“networkProfile”: {

“networkInterfaceConfigurations”: [

{

“name”: “lilila97cNic”,

“properties”: {

“dnsSettings”: {

“dnsServers”: []

},

“enableAcceleratedNetworking”: false,

“ipConfigurations”: [

{

“name”: “lilila97cIPConfig”,

“properties”: {

“loadBalancerBackendAddressPools”: [

{

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d429f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/loadBalancers/lililabdcLB/backendAddressPools/lililabdcLBBEPool”,

“resourceGroup”: “myazurelab001”

}

],

“loadBalancerInboundNatPools”: [

{

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d429f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/loadBalancers/lililabdcLB/inboundNatPools/lililabdcLBNatPool”,

“resourceGroup”: “myazurelab001”

}

],

“privateIPAddressVersion”: “IPv4”,

“subnet”: {

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d429f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/virtualNetworks/vnet001/subnets/snet001”,

“resourceGroup”: “myazurelab001”

}

}

}

],

“primary”: true

}

}

]

},

“osProfile”: {

“adminUsername”: “liliana”,

“computerNamePrefix”: “lilila97c”,

“secrets”: [],

“windowsConfiguration”: {

“enableAutomaticUpdates”: true,

“provisionVMAgent”: true

}

},

“storageProfile”: {

“imageReference”: {

“offer”: “WindowsServer”,

“publisher”: “MicrosoftWindowsServer”,

“sku”: “2012-R2-Datacenter”,

“version”: “latest”

},

“osDisk”: {

“caching”: “ReadWrite”,

“createOption”: “FromImage”,

“managedDisk”: {

“storageAccountType”: “Standard_LRS”

}

}

}

}

}

}

az>> az vmss list-instance-connection-info -g myazurelab001 –name lililabdc

{

“instance 0”: “52.179.172.137:50000”,

“instance 2”: “52.179.172.137:50002”

}

az>>

Conect AzureVM

You can manage your virtual machines directly on PowerShell using the Windows Remote Managing or WinRM and a PowerShell technique called Remote Shell, but locally.. so how you can use the same with you Azure VMs. let’s run this Script and wonder with the potential of this RemoteShell…

<#PSScriptInfo

.VERSION 1.0
.GUID b66368a8-dc27-481a-b4f3-dff65a6d42ee
.AUTHOR Azure-Automation-Team
.COMPANYNAME Microsoft
.COPYRIGHT
.TAGS AzureAutomation OMS VirtualMachines Utility
.LICENSEURI
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>
#Requires -Module Azure
<#
.DESCRIPTION
This runbook sets up a connection to an Azure virtual machine. It requires the Azure virtual machine to
have the Windows Remote Management service enabled, which is the default. It sets up a connection to the Azure
subscription and then imports the certificate used for the Azure VM so remote PowerShell calls can be made to it.
#>
Param()
<#
.SYNOPSIS
Sets up the connection to an Azure VM
.DESCRIPTION
This runbook sets up a connection to an Azure virtual machine. It requires the Azure virtual machine to
have the Windows Remote Management service enabled, which is the default. It sets up a connection to the Azure
subscription and then imports the certificate used for the Azure VM so remote PowerShell calls can be made to it.
.PARAMETER AzureSubscriptionName
Name of the Azure subscription to connect to.

.PARAMETER AzureOrgIdCredential
A credential containing an Org Id username / password with access to this Azure subscription.

 If invoking this runbook inline from within another runbook, pass a PSCredential for this parameter.
 If starting this runbook using Start-AzureAutomationRunbook, or via the Azure portal UI, pass as a string the
name of an Azure Automation PSCredential asset instead. Azure Automation will automatically grab the asset with
that name and pass it into the runbook.
.PARAMETER ServiceName
Name of the cloud service where the VM is located.
.PARAMETER VMName
Name of the virtual machine that you want to connect to.
.EXAMPLE
Connect-AzureVM -AzureSubscriptionName “Visual Studio Ultimate with MSDN” -ServiceName “Finance” -VMName “WebServer01” -AzureOrgIdCredential $cred
.NOTES
AUTHOR: System Center Automation Team
LASTEDIT: Dec 18, 2014
#>
workflow Connect-AzureVM
{
[OutputType([System.Uri])]
    Param
(
[parameter(Mandatory=$true)]
[String]
$AzureSubscriptionName,
  [parameter(Mandatory=$true)]
[PSCredential]
$AzureOrgIdCredential,

[parameter(Mandatory=$true)]
[String]
$ServiceName,

[parameter(Mandatory=$true)]
[String]
$VMName
)

Add-AzureAccount -Credential $AzureOrgIdCredential | Write-Verbose

 # Select the Azure subscription we will be working against
Select-AzureSubscription -SubscriptionName $AzureSubscriptionName | Write-Verbose
    InlineScript {
# Get the Azure certificate for remoting into this VM
$winRMCert = (Get-AzureVM -ServiceName $Using:ServiceName -Name $Using:VMName | select -ExpandProperty vm).DefaultWinRMCertificateThumbprint
$AzureX509cert = Get-AzureCertificate -ServiceName $Using:ServiceName -Thumbprint $winRMCert -ThumbprintAlgorithm sha1
        # Add the VM certificate into the LocalMachine
if ((Test-Path Cert:\LocalMachine\Root\$winRMCert) -eq $false)
{
Write-Progress “VM certificate is not in local machine certificate store – adding it”
$certByteArray = [System.Convert]::fromBase64String($AzureX509cert.Data)
$CertToImport = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList (,$certByteArray)
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store “Root”, “LocalMachine”
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
$store.Add($CertToImport)
$store.Close()
}

# Return the WinRM Uri so that it can be used to connect to this VM
Get-AzureWinRMUri -ServiceName $Using:ServiceName -Name $Using:VMName
}
}

Manage your AzureVMs

If you are handling by first time the Azure subscription, you can put the face as sitting in the millennial falcon… what this button stands for??

don’t worry, Azure is bringing so much that is simply impossible to afford all in a month. you keep learning all the time about it.

The Azure team, and the Office 365 got a plan, and they bring new capabilities every couple of weeks. as MCT we get a message directly from corp. where we was clearly advised to handle this courses with the actual material, and this MOC will be updated more frequently, than regular ones.

so, get back to the intention of this post. how can I manage my remaining U$200 of my trial, and stretch it so much as I can. well. first, if you’re patient, use the GUI and turn on/off your machines every time you’re gonna use them. if you don’t, try installing the Azure PowerShell module, https://azure.microsoft.com/en-us/downloads/ and then run the following  script to start your AzureVMs.

——————————————————-
Start-AzureVM -ServiceName CloudDemo001 -Name BOGDC01
——————————————————-
Import-module azure
Import-AzurePublishSettingsFile -PublishSettingsFile ‘c:\users\fcamp\Downloads\MSDN-11-5-2015-credentials.publishsettings’
Param(
[string]$servicename,
[string]$name,
[string]$userName,
[string]$password
)
$servicename = ‘CloudDemo001’
#get-AzureVM -ServiceName CloudDemo001 |ft
$name = ‘BOGDC01’
$userName = ‘admin’
$password = “WarMachineIsTheBest”
$vm = Get-AzureVM -ServiceName $servicename -Name $name
If ($vm.InstanceStatus -ne ‘ReadyRole’)
{
Write-Host (“VM is not running. InstanceStatus:” + $vm.instancestatus)
}
Else
{
$port = ($vm.VM.ConfigurationSets.Inputendpoints | Where { $_.LocalPort -eq 5986 }).Port
$vip = ($vm.VM.ConfigurationSets.Inputendpoints | Where { $_.LocalPort -eq 5986 }).Vip
$uri = (‘https://&#8217; + $vip + ‘:’ + $port)

$Credential = New-Object System.Management.Automation.PSCredential($username, $(ConvertTo-SecureString -String $password -AsPlainText -Force))
$SessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck -NoMachineProfile
$PSSession = New-PSSession -ConnectionUri $uri -Credential $Credential -SessionOption $SessionOption

Enter-PSSession $PSSession
}

——————————————————-
Stop-AzureVM -ServiceName CloudDemo001 -Name BOGDC01
——————————————————-
Function Get-Uptime {
<#
.SYNOPSIS
Displays Uptime since last reboot
.PARAMETER  Computername
.EXAMPLE
Get-Uptime Server1
.EXAMPLE
“Server1”, “Server2″|Get-Uptime
.EXAMPLE
(Get-Uptime Sever1).”Time Since Last Reboot”
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$True,ValueFromPipeline=$true,Position=0)]
[STRING[]]$Computername
)

Begin {Write-Verbose “Version 1.00”}

Process {
$Now=Get-Date
$LastBoot=[System.Management.ManagementDateTimeConverter]::ToDateTime((Get-WmiObject win32_operatingsystem -ComputerName $computername).lastbootuptime)
$Result=@{ “Server”=$($Computername);
“Last Reboot”=$LastBoot;
“Time Since Reboot”=”{0} Days {1} Hours {2} Minutes {3} Seconds” -f ($Now – $LastBoot).days, `
($Now – $LastBoot).hours,($Now – $LastBoot).minutes,($Now – $LastBoot).seconds}
Write-Output (New-Object psobject -Property $Result|select Server, “Last Reboot”, “Time Since Reboot”)
}
}

Connect Office 365

Once you have you PC/PowerShell prepared, you can connect to Office 365, using a simple script as this, where you define your username, and thereafter you can simply click it. don’t forget, you use the dollar sign $ to generate PSvariables.

$User = “sysadmin@MyDomain.info”
$Pass = ConvertTo-SecureString “TheWarMachineIsTheBest.” -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $Pass
Import-Module MSOnline
Connect-msolservice -Credential $Cred
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection
Import-PSSession $Session
#Import-Module LyncOnlineConnector
#import-module microsoft.online.sharepoint.powershell
#$Session = New-CsOnlinesession -Credential $Cred
#Import-PSSession $Session
#[string]$tenant = get-msoldomain | where {$_.name -like “*.onmicrosoft.com” -and -not($_.name -like “*mail.onmicrosoft.com”)} | select name
#$tenant
#$tenant3 = $tenant -split(“=”)
#[string]$tenant4 = $tenant3[1]
#$tenant4
#$tenant5 = $tenant4 -split(“.on”)
#[string]$tenant6 = $tenant5[0]
#$url = “https://&#8221; + $tenant6 + “-admin.sharepoint.com”
#Connect-SPOService -Url $url -credential $Cred