Friday, November 30, 2018

Azure and Office 365 PowerShell


Office 365

Recycle Bin - 2019.3
https://lazyadmin.nl/powershell/restore-recycle-bin-sharepoint-online-with-powershell/

Flow - How to Disable the Flow button in SharePoint Online - 2019.3
https://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=786

Useful PowerShell cmdlets to administer Office 365 Groups - 2019.3
https://vigneshsharepointthoughts.com/2018/05/16/useful-powershell-cmdlets-to-administer-office-365-groups/

Teams – 2019.3
http://sharepoint-tricks.com/manage-your-teams-on-microsoft-teams

SharePoint – Site Design - 2019.3
https://drewmadelung.com/powershell-for-sharepoint-site-designs-site-scripts

55238 PowerShell Lab A

New-MsolUser –UserPrincipalName pete@CKXXXX.onmicrosoft.com –DisplayName “Pete Coventry” –FirstName “Pete” –LastName “Coventry” –Password ‘NH-1Train’ -ForceChangePassword $false –UsageLocation “GB”

New-MsolUser –UserPrincipalName ashley@CKXXXX.onmicrosoft.com –DisplayName “Ashley Curtis” –FirstName “Ashley” –LastName “Curtis” –Password ‘NH-1Train’ -ForceChangePassword $false –UsageLocation “GB”

New-MsolUser –UserPrincipalName mark@CKXXXX.onmicrosoft.com –DisplayName “Mark Summers” –FirstName “Mark” –LastName “Summers” –Password ‘NH-1Train’ -ForceChangePassword $false –UsageLocation “GB”

New-MsolUser –UserPrincipalName shannen@CKXXXX.onmicrosoft.com –DisplayName “Shannen Smith” –FirstName “Shannen” –LastName “Smith” –Password ‘NH-1Train’ -ForceChangePassword $false –UsageLocation “GB”

New-MsolUser –UserPrincipalName sarah@CKXXXX.onmicrosoft.com –DisplayName “Sarah Manley” –FirstName “Sarah” –LastName “Manley” –Password ‘NH-1Train’ -ForceChangePassword $false –UsageLocation “GB”

Get-Msoluser

Get-Msoluser –unlicensedusersonly

Set-MsolUserLicense -UserPrincipalName pete@CKXXXX.onmicrosoft.com –AddLicenses“CKXXXX:ENTERPRISEPREMIUM”

Set-MsolUserLicense -UserPrincipalName ashely@CKXXXX.onmicrosoft.com –AddLicenses“CKXXXX:ENTERPRISEPREMIUM”

Set-MsolUserLicense -UserPrincipalName mark@CKXXXX.onmicrosoft.com –AddLicenses“CKXXXX:ENTERPRISEPREMIUM”

Set-MsolUserLicense –UserPrincipalName sarah@CKXXXX.onmicrosoft.com –AddLicenses“CKXXXX:ENTERPRISEPREMIUM”

Set-MsolUserLicense –UserPrincipalName shannen@CKXXXX.onmicrosoft.com –AddLicenses“CKXXXX:ENTERPRISEPREMIUM”

Get-Msoluser

Additional Learning

$unlicensed = Get-Msoluser –unlicensedusersonly
$license = “CKXXXX:ENTERPRISEPREMIUM”

Set-MsolUserLicense –UserPrincipalName $unlisensed[0].userprinciplename–AddLicenses $license

55238 PowerShell Lab B

Connect-SPOService –Url https://CKXXXXX-admin.sharepoint.com –credentialzoe@CKXXXX.onmicrosoft.com

New-SPOSite -Url https://CKXXXX.sharepoint.com/sites/hr -title "HR Home" –Owner zoe@CKXXXX.onmicrosoft.com -storagequota 1024 -Template STS#0

Get-SPOSite

https://drm.combined-knowledge.com/cklabs/spoadmin/labs.zip

Import-Csv .\NewSPOSites.csv| % {New-SPOSite -Owner $_.Owner –StorageQuota $_.StorageQuota -Url $_.Url -NoWait -ResourceQuota $_.ResourceQuota –Template $_.Template -Title $_.Name}

Get-SPOSite

Set-SPOUser -site https://CKXXXX.sharepoint.com/sites/hr –LoginName pete@CKXXXX.onmicrosoft.com -IsSiteCollectionAdmin $True

Get-SPOUser -Site https://CKXXXX.sharepoint.com/sites/hr | where {$_.IsSiteAdmin}

$spoSites=Get-SPOSite | Select *

foreach($spoSite in $spoSites)

{

Write-Host "Admins for " $spoSite.Url -foregroundcolor Yellow

Get-SPOUser -Site $spoSite.Url | where {$_.IsSiteAdmin}

Write-Host

}

Set-SPOSite -identity https://CKXXXX.sharepoint.com/sites/intranet –StorageQuota 15000 -StorageQuotaWarningLevel 13000

$spoSites=Get-SPOSite | Select *

foreach($spoSite in $spoSites)

{

Write-Host "Changing Quota for " $spoSite.Url -foregroundcolor Yellow

Set-SPOSite -identity $spoSite.URL -StorageQuota 12500 -StorageQuotaWarningLevel 11000

Write-Host

}

Remove-SPOSite https://CKXXXX.sharepoint.com/sites/ProjectSite

Remove-SPODeletedSite https://CKXXXX.sharepoint.com/sites/ProjectSite


Legacy – Azure O365

SharePoint Online Management Shell
http://www.microsoft.com/en-us/download/details.aspx?id=35588
Office 365 cmdlets will make working with SharePoint Online very similar to working with SharePoint on-premises.
Creating List and Libraries using CSOM
http://sharepoint-community.net/profiles/blogs/powershell-import-list-items-from-csv-client-object-model

Scripting Guys – Always Great Start to Your Day
 http://blogs.technet.com/b/heyscriptingguy/archive/2014/03/28/manage-office-365-sharepoint-with-modules.aspx
Gary Lapointe – PowerShell Author
http://blog.falchionconsulting.com/index.php/2014/01/announcing-my-custom-sharepoint-online-cmdlets
Create Folder in Office 365
http://www.enjoysharepoint.com/Articles/Details/create-folders-csom-powershell-script-office-365-sharepoint-online-21042.aspx

Windows Azure Active Directory Module for Windows PowerShell

First you need the modules …
Using Server 2012 no issues, install Microsoft Online Services Sign-in Assistant and AD Module, no issues.
http://technet.microsoft.com/en-us/library/jj151815.aspx
I followed this with no luck on Windows 7 on 32 bit, appears there is a bug and the fix is to run the beta software for the Microsoft Online Services Sign-in Assistant. (shaking my head)
http://social.msdn.microsoft.com/Forums/windowsazure/en-US/46a38822-28a4-4abb-b747-96f7db2a2676/cannot-install-azure-active-directory-module-for-windows-powershell-mossia-is-not-installed

Now that is is loaded it is fairly simple to test.  Start my opening the new Icon on your desktop.
You need to set your credentials and pass that to Microsoft Office 365.  Making sure to logon using admin@yourdemodomain.onmicrosoft.com

$msolcred = get-credential
connect-msolservice -credential $msolcred

Now test my simply running a command to get your users.
Get-MsolUser
 
More tests - Admin Roles
Get-MsolRole | select name,description | ft –autosize
 
More Tests – Domain Info
Get-MsolDomain
 
More Tests – Subscription Info
Get-MsolSubscription
Get-MsolAccountSku

SharePoint Online Management Shell


So for SharePoint Online Management Shell the step are very similar to Office 365. First set your variable for both your admin credentials and website.  Next run the connect command both Office 365 and SharePoint Online. Once you successfully run both command you get no errors just a returned prompt.  So here are the commands noting that the domain is contoso.sharepoint.com
Logon to Office 365 with you admin account and go to the admin screen for SharePoint, this account later used for $mycred variable.
 
Look at the admin address since this will give you the right URL to manage and will use for $mysite variable.
Run the following commands in the new SharePoint Online Management Shell
 
$mycred = get-credential
$mysite = ‘https://contoso-admin.sharepoint.com”
connect-msolservice -credential $mycred
connect-SPOService -Url $mysite -credential $mycred

test using the following commands:
get-msoluser
get-sposite

Help


http://powershell.office.com/

Subscription


http://dev.office.com/