Tuesday, December 18, 2018

PowerShell 101 - Basics


How to get Help

https://docs.microsoft.com/en-us/powershell

Help
Get-Help
Help vs Get-Command
search command using Bing or google

Search using https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/?view=powershell-6

How to Edit

Tab Complete
History

What is Piping?

Select
More

example: Get-Process | More
example: Get-Process | Select * | More

example: Get-Command | Measure-Object

Variables?

variables
collections
array
Get-Member

example: $temp = Get-Process
example: $temp | Get-Member
example: $temp = Get-Process[0]


Note if help files are missing run update-help or go here to help online


How to get Help

Help
Get-Help
Help vs Get-Command
search

How to Edit

Tab Complete
History

What is Piping?

Select
More
Measure

Variables?

collections
array
get member

Editor

Command line vs ISE

Keyboard Shortcuts

https://msdn.microsoft.com/en-us/powershell/scripting/core-powershell/ise/keyboard-shortcuts-for-the-windows-powershell-ise
https://technet.microsoft.com/en-us/library/ff678293.aspx

Tuesday, December 4, 2018

SharePoint PowerShell 2013 Reference Guide

SharePoint PowerShell from 20331 and 20332

Managed Metadata

New-ADUser -SamAccountName SPSalesMMS -Name "SharePoint Sales MMS" -UserPrincipalName "SPSalesMMS@contoso.com" -AccountPassword (Read-host “enter password” -AsSecureString) -Path “OU=SharePoint,DC=Contoso,DC=com” -Enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false

New-SPManagedAccount

$AppPool = New-SPServiceApplicationPool -Name ContosoSalesMMSAppPool -Account SPSalesMMS@contoso.com

$MMS = New-SPMetadataServiceApplication -Name "Contoso Sales Managed Metadata" -ApplicationPool $AppPool -DatabaseName ContosoSalesMMS -HubUri http://sales.contoso.com

New-SPMetadataServiceApplicationProxy -Name "Contoso Sales Managed Metadata" -ServiceApplication $MMS –DefaultProxyGroup

State Service

$serviceApp = New-SPStateServiceApplication -Name "StateService-App"

New-SPStateServiceDatabase -Name "SS-Database" -ServiceApplication $serviceApp

New-SPStateServiceApplicationProxy -Name "StateService-App" -ServiceApplication $serviceApp -DefaultProxyGroup

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/

Wednesday, February 21, 2018

PowerShell Courses Books Tools and Training

Free Books

List of Free PowerShell eBooks (11-2018)
https://www.hofferle.com/list-of-free-powershell-ebooks/

List of Free Books – PowerShell

 https://cincypowershell.org/Resources/

Huge List of Free Books – Including PowerShell

http://thecloudengineer.blogspot.com/2011/12/sharepointbooks.html

Free Microsoft Books – Including PowerShell

http://thecloudengineer.blogspot.com/2011/12/sharepointbooks.html

Free eBooks – PowerShell

https://powershell.org/category/books

https://leanpub.com/u/devopscollective

Scripting Guy
http://blogs.technet.com/b/heyscriptingguy/

Windows PowerShell Survival Guide (11-2018)
https://social.technet.microsoft.com/wiki/contents/articles/183.windows-powershell-survival-guide.aspx

Free Training

PowerShell and Active Directory Essentials

https://info.varonis.com/thank-you/course/powershell

Latest Books Recommended by Students

PowerShell for Dummies
https://www.amazon.com/Windows-PowerShell-Dummies-Steve-Seguis/dp/0470371986/ref=sr_1_1

Learn Windows PowerShell in a Month of Lunches

https://www.amazon.com/Learn-Windows-PowerShell-Month-Lunches/dp/1617294160/ref=sr_1_1

Great list from Ashley McGlone
https://blogs.technet.microsoft.com/ashleymcglone/2016/04/01/powershell-video-training-from-microsoft/   

Examples

Find Duplicate Files With PowerShell (11-2018)
http://blog.codeassassin.com/2007/10/13/find-duplicate-files-with-powershell/

Tools

Idera PowerShell Plus is now free
Free tool to learn and master PowerShell fast

  • Learn PowerShell fast with the interactive learning center
  • Execute PowerShell quickly and accurately with a Windows UI console
  • Access, organize and share pre-loaded scripts from the QuickClick™ library
  • Code & Debug PowerShell 10X faster with the advanced script editor
https://www.idera.com/Free-Tools/PowerShell-Plus/

User Groups


Cincy OH -
http://powershellgroup.org/cincinnati.oh
Columbus OH - http://powershellgroup.org/central.oh

Older Books on PowerShell


General - Must Have!

Automating Microsoft Windows Server 2008 R2 with Windows PowerShell 2.0
Windows PowerShell 2.0 allows you to automate nearly any task for managing Windows Server, going from dozens of clicks to a single command, and repeated tasks to automated tasks. Using screen shots and helpful exercises, this book walks you through the many benefits of automating Windows Server with PowerShell 2.0, such as allowing for scalable, flexible, and rapid deployments and changes; increasing cost effectiveness; providing a timely return on IT investment; lowering labor headcount; creating secure computing environments; and establishing reliable enterprise infrastructures. In addition, real-world examples provide reinforced learning, aimed at ensuring that you work as efficiently and effectively as possible by automating both simple and complex administrative tasks with Powershell 2.0.
Details from
Wiley Publishing  Matt Hester http://blogs.technet.com/b/matthewms/

SharePoint - Must Have!

Automating SharePoint 2010 with Windows PowerShell 2.0
Imagine being able to perform a task that requires dozens of clicks with just a single command, or automate a series of identical tasks rather than repeat them. This book shows you how to do just that?and more?by using Windows PowerShell cmdlets with SharePoint 2010. Focused on everyday and frequently performed tasks, this invaluable guide provides PowerShell solutions for maintaining a SharePoint environment and explains how more than 500 cmdlets that come with SharePoint 2010 allows you to automate just about anything. Step-by-step instructions walk you through the necessary concepts and real-world examples enhance your learning process.
Details from
Amazon  Gary LaPoint http://blog.falchionconsulting.com/

Recommended by students ...

Windows PowerShell 2 For Dummies
Prepare for the future of Microsoft automation with this no-nonsense guide
Windows PowerShell 2 is the scripting language that enables automation within the Windows operating system. Packed with powerful new features, this latest version is complex, and Windows PowerShell 2 For Dummies is the perfect guide to help system administrators get up to speed.
Written by a Microsoft MVP with direct access to the program managers and developers, this book covers every new feature of Windows PowerShell 2 in a friendly, easy-to-follow format.
  • Windows PowerShell 2 is the updated scripting language that enables system administrators to automate Windows operating systems
  • System administrators with limited scripting experience will find this book helps them learn the fundamentals of Windows PowerShell 2 quickly and easily
  • Translates the jargon and complex syntax of Windows PowerShell 2
  • Covers script debugging improvements, the ability to invoke commands remotely, and the new user interface
  • Uses real-world applications to clarify the theory, fundamentals, and techniques of the scripting language
  • Written by a Microsoft MVP with direct access to the developers of Windows PowerShell 2
Windows PowerShell 2 For Dummies makes this tool easily accessible to administrators of every experience level.


Training Courses



10325A Automating Administration with Windows PowerShell 2.0

This course provides students with the knowledge and skills  to utilize Windows PowerShell for administering and automating administration of  Windows based servers. This course is intended for IT Professionals already  experienced in general Windows Server and Windows Client administration,  including Active Directory administration. No prior experience with any version  of Windows PowerShell, or any scripting language, is assumed. Topics covered include:

10961 Automating Administration with Windows PowerShell 3.0
Learn how with Windows PowerShell 3.0, you can remotely manage single or multiple Windows-based servers and automate day-to-day management and administration tasks.
This five day course provides students with the fundamental knowledge and skills to use Windows PowerShell 3.0 for administering and automating administration of Windows based servers. It focuses on primary Windows PowerShell command-line features and techniques, and will provide prerequisite skills supporting many different Microsoft products. This includes Windows Server, Windows Client, Exchange Server, SharePoint Server, SQL Server, System Center, and more. In keeping with that goal, this course will not focus on any one of those products, although Windows Server (which is the common platform for all of those) will serve as the example for the techniques being taught.

MVA


Basic - http://www.microsoftvirtualacademy.com/training-courses/getting-started-with-powershell-3-0-jump-start
Advanced - http://www.microsoftvirtualacademy.com/training-courses/advanced-tools-scripting-with-powershell-3-0-jump-start

Intermediate | Published: 30 July 2013  | Getting Started with Microsoft PowerShell
Instructor(s):
Jason Helmick and Jeffrey Snover


https://mva.microsoft.com/en-us/training-courses/getting-started-with-microsoft-powershell-8276?l=r54IrOWy_2304984382