WordPress.com
1 Pipeline.ps1#Open as admincd\; cls#Strings in the pipeline"Print Spooler" | Get-Service"Print Spooler", "Windows Update" | Get-Service"Print Spooler", "Windows Update" | Stop-Service # Requires Admin# use of the $_ pipeline placeholder variable"Steak", "Wine", "Pie" | ForEach-Object {$_ + " is one of my favorite foods" }"Steak", "Wine", "Pie" | Where-Object { $_ -like '*eak'}Get-Service | Where-Object { $_.Displayname -eq "Print Spooler" }2 ISE, object types, common functions.ps1cls#Auto-complete, get-helpGet-Help Get-Service -OnlineGet-Service "Print Spooler" | Select-Object *#String"Just a line of text""1"#Integer123#ArrayGet-Service#using the .GetType method("Just a line of text").GetType()(123).GetType()(Get-Service).GetType()#Hash Tables@{Sky = "Blue";Grass="green";Road="Black"}@{ Sky = "Blue" Grass="green" Road="Black"}#use of commas to seperate values1,2,3,4,5#Where-Object1,2,3,4,5 | Where-Object {$_ -gt 3}#Foreach-Object1,2,3,4,5 | ForEach-Object {$_ + 100} 3 ISE Scripts (Play, Play Section), Debug.ps1# to ExO from next tab$AllMailboxes = Get-Mailbox$StatsForAllMailboxes = $AllMailboxes | Get-MailboxStatistics$StatsForAllMailboxes | select DisplayName, TotalItemSize, LastLogonTimeWrite-Host "We're done!!!" -ForegroundColor Cyan4 ConnectToAzureAndExo.ps1#Setup Credentials$DemoAdmin = 'demoadmin@demo84384.'### Password Save Options#1#Plaintext Password$DemoAdminPassword = 'MyPassw0rd'#2#More Secure$DemoAdminPassword = Get-Content C:\Users\Demo\Desktop\demoFiles\Sources\DemoPWString.txt | ConvertTo-SecureString$DemoPass = ConvertTo-SecureString -AsPlainText -String $DemoAdminPassword -Force$DemoCred = New-Object System.Management.Automation.PSCredential -ArgumentList $DemoAdmin, $DemoAdminPassword#3#Most Secure# $DemoCred = Get-StoredCredential -Name outlook.# Setup Hash Table for Splatting ()$Session = @{ ConfigurationName = 'Microsoft.Exchange' ConnectionUri = '' Authentication = 'basic' Credential = $DemoCred AllowRedirection = $true }#Connect to Exchange OnlineImport-PSSession (New-PSSession @Session)#Connect to Azure ADConnect-MsolService -Credential $DemoCred 5 CreateUsers, Misc.ps1[Reflection.Assembly]::LoadWithPartialName("System.Web") # always reliable passwords for msolcd \cls#Create a single userNew-MsolUser -FirstName "Mike" -LastName "Crowley" -DisplayName "Mike Crowley" -UserPrincipalName "MCrowley@demo84384." -UsageLocation "US"#Import-CsvImport-Csv "C:\Users\Demo\Desktop\demoFiles\Sources\10AzureUsers.csv"#Create users from a CSV file - Matching headersImport-Csv "C:\Users\Demo\Desktop\demoFiles\Sources\10AzureUsers.csv" | New-MsolUser#View newly created usersclsGet-MsolUser -All #Count the users with measure-object and the .count methodGet-MsolUser -All | Measure-Object(Get-MsolUser -All).Count#Remove those usersImport-Csv "C:\Users\Demo\Desktop\demoFiles\Sources\10AzureUsers.csv" | Remove-MsolUser -ForceGet-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force#Create users from a CSV file - NON-matching headers - using a variable$CustomHeadersCSV = Import-Csv "C:\Users\Demo\Desktop\demoFiles\Sources\10AzureUsers-CustomHeaders.csv"$CustomHeadersCSV | ForEach-Object { New-MsolUser -FirstName $_.givenname -LastName $_.surname -DisplayName $_.display -UserPrincipalName $_.upn -UsageLocation $_.country -Password $_.pass }#Remove those users, using foreach, because the CSV no longer has matching headers$CustomHeadersCSV | ForEach-Object {Remove-MsolUser -UserPrincipalName $_.UPN -Force}Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force#Improved readability with backticks$CustomHeadersCSV | ForEach-Object { New-MsolUser ` -FirstName $_.givenname ` -LastName $_.surname ` -DisplayName $_.display ` -UserPrincipalName $_.upn ` -UsageLocation $_.country ` -Password $_.pass ` }#Remove those users$CustomHeadersCSV | ForEach-Object {Remove-MsolUser -UserPrincipalName $_.UPN -Force}Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force#Improved readability with spalatting - also using expressions for values$FirstLastOnlyCSV = Import-Csv "C:\Users\Demo\Desktop\demoFiles\Sources\10AzureUsers-FirstLastOnly.csv"$FirstLastOnlyCSV | ForEach-Object { $UserParameters = @{ FirstName = $_.givenname LastName = $_.surname DisplayName = $_.givenname + " " + $_.surname UserPrincipalName = $_.givenname[0] + $_.surname + "@demo84384." UsageLocation = "US" Password = [System.Web.Security.Membership]::GeneratePassword(9,2) } New-MsolUser @UserParameters }#View newly created usersclsGet-MsolUser -All 6 Comments.ps1<#.SYNOPSISThe synopsis goes here. This can be one line, or many..DESCRIPTIONThe description is usually a longer, more detailed explanation of what the script or function does. Take as many lines as you need..PARAMETER computernameHere, the dotted keyword is followed by a single parameter name. Don't precede that with a hyphen. The following lines describe the purpose of the parameter:.PARAMETER filePathProvide a PARAMETER section for each parameter that your script or function accepts..EXAMPLEThere's no need to number your examples..EXAMPLEPowerShell will number them for you when it displays your help text to a user.#>#Read more: get-help outputGet-Help New-InboxRule#Test the above comment sectionGet-Help 'C:\Users\Demo\Desktop\demoFiles\PS\6 Comments, Variable Types & Scopes.ps1'#show all detailGet-Help 'C:\Users\Demo\Desktop\demoFiles\PS\6 Comments, Variable Types & Scopes.ps1' -Full#Simple Comment. no code is executed after a # on this lineGet-AcceptedDomain #get the accepted domains<# This comment style allows me to use multiple lines which can be useful if your comments are long#>7 Date Spans (message trace), XML.ps1#Examples of DateTime objects$Sep1 = get-date 9/1/2015$Oct1 = get-date 10/1/2015$Sep1.GetType()#Example of a TimeSpan objects$Delta = $Oct1 - $Sep1$Delta$Delta.GetType()#Sample use of datesGet-MessageTrace -StartDate $Sep1 -EndDate $Oct1#Example of adding date spans to dates$RightNow = Get-Date$RightNow + $Delta#The .AddDays method($RightNow).AddDays(1)($RightNow).AddDays(-1)Get-MessageTrace -StartDate (get-date).AddDays(-2) -EndDate (Get-Date)#XML CmdletsGet-Command *xml*[xml]$AzureIPRangesInXml2 = Get-Content C:\Users\Demo\Desktop\demoFiles\Sources\PublicIPs_20150914.xml$AzureIPRangesInXml2.AzurePublicIpAddresses.Region | Where Name -eq USWest | Select -expand IPrange8 Licensing.ps1cls#See what licenses are available and what properties each object hasGet-MsolAccountSku | select *#Assign the licenseSet-MsolUser -UserPrincipalName MBrown@demo84384. -UsageLocation USSet-MsolUserLicense -UserPrincipalName MBrown@demo84384. -AddLicenses demo84384:ENTERPRISEPACK#Look at the ServiceStatus object, nested within the output of get-msolaccoutskuGet-MsolAccountSku | select -expand servicestatus#Prepare Student License Object#Read here for more: $NonExchangeOptions = @( "INTUNE_O365" "YAMMER_ENTERPRISE" "RMS_S_ENTERPRISE" "OFFICESUBSCRIPTION" "MCOSTANDARD" "SHAREPOINTWAC" "SHAREPOINTENTERPRISE" )#Create a custom license object$MyCustomLicense = New-MsolLicenseOptions -AccountSkuId demo84384:ENTERPRISEPACK -DisabledPlans $NonExchangeOptions#Assign the licenseSet-MsolUser -UserPrincipalName iwilson@demo84384. -UsageLocation USSet-MsolUserLicense -UserPrincipalName iwilson@demo84384. -AddLicenses demo84384:ENTERPRISEPACK -LicenseOptions $MyCustomLicense9 Output & GUI Elements.ps1# 1 #GridView#Get-Mailbox | Out-GridViewGet-Mailbox | select * | Out-GridView# 2#User Yes/No Button# [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')? ? $ButtonSelection?=?[Microsoft.VisualBasic.Interaction]::MsgBox("Should the ENTERPRISEPACK license be assigned to newly imported users?",?'YesNoCancel,Question',?"Respond please")? ? switch?($ButtonSelection) {? ??'Yes'???????{?Set-MsolUserLicense...?}? ??'No'????????{?Write-Verbose "Skipping License Assignment Step"?}? ??'Cancel'????{?Write-host "Exiting"; Sleep 3; exit?}? }# 3## ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- wordpress passing data between pages
- wordpress business templates
- wordpress rss feed not working
- wordpress jquery is not defined
- create wordpress blog
- wordpress roles editor
- wordpress full rss feed
- wordpress rss feed settings
- wordpress rss feed plugin
- wordpress display rss feed
- wordpress rss feed link
- wordpress rss feed to post