xml PowerShell:设置Exchange OnlineConfigurations <br/> #PowerShell <br/> #ExchangeOnline <br/>#Office365

PowerShell:设置Exchange OnlineConfigurations <br/> #PowerShell <br/> #ExchangeOnline <br/>#Office365

Set-EOConfig.ps1
<#
$Metadata = @{
	Title = "Set Exchange Online Configurations"
	Filename = "Set-EOConfig.ps1"
	Description = ""
	Tags = "powershell, office, 365, exchange, online, settings"
	Project = ""
	Author = "Janik von Rotz"
	AuthorContact = "http://janikvonrotz.ch"
	CreateDate = "2014-01-21"
	LastEditDate = "2014-01-21"
	Url = "https://gist.github.com/6294947"
	Version = "1.0.0"
	License = @'
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Switzerland License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ch/ or 
send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
'@
}
#>

try{

    #--------------------------------------------------#
    # settings
    #--------------------------------------------------#

    $Language = "de-CH"
    $TimeZone = "W. Europe Standard Time"
    $DateFormat = "dd.MM.yyyy"
    $HtmlSignatureTemplate = "vbl signature.html"
    $TextSignatureTemplate = "vbl signature.txt"
    $SignatureCompanyPhoneNumber = "+41 41 369 65 65"
    $SignatureCompanyFaxNumber = "041 369 65 00"
    
    #--------------------------------------------------#
    # modules
    #--------------------------------------------------#
    Import-Module ActiveDirectory       

    #--------------------------------------------------#
    # sessions
    #--------------------------------------------------#

    $Credential = Import-PSCredential $(Get-ChildItem -Path $PSconfigs.Path -Filter "Office365.credentials.config.xml" -Recurse).FullName
    
    $s = New-PSSession -ConfigurationName Microsoft.Exchange `
    -ConnectionUri https://ps.outlook.com/powershell `
    -Credential $(Get-Credential -Credential $Credential) `
    -Authentication Basic `
    -AllowRedirection
    Import-PSSession $s

    #--------------------------------------------------#
    # main
    #--------------------------------------------------#

    $ADUsers = Get-ADUser -Filter {Mail -like "*"} -Properties sn, telephoneNumber, title
    $Mailboxes = Get-Mailbox

    foreach($Mailbox in $Mailboxes){
        
        Write-Progress -Activity "Update settings" -status $($Mailbox.Name) -percentComplete ([Int32](([Array]::IndexOf($Mailboxes, $Mailbox)/($Mailboxes.count))*100))

        Write-Host "Set mailbox language settings for $($Mailbox.Name)"
        Set-MailboxRegionalConfiguration $Mailbox.Alias -Language $Language -TimeZone $TimeZone -LocalizeDefaultFolderName -DateFormat $DateFormat

        Write-Host "Set signature for $($Mailbox.Name)"
        $ADUsers | where{$_.UserPrincipalName -eq $Mailbox.UserPrincipalName} | select -First 1 | %{           

            $Html = get-Content -Path $(Get-ChildItem -Path $PStemplates.Path -Filter $HtmlSignatureTemplate -Recurse).FullName  
            $Text = get-Content -Path $(Get-ChildItem -Path $PStemplates.Path -Filter $TextSignatureTemplate  -Recurse).FullName  
            
            $PhoneNumber = $(if($_.telephoneNumber -eq $null){$SignatureCompanyPhoneNumber}else{$_.telephoneNumber})

            $Html = $Html -replace "%%Firstname%%",$_.givenname `
                -replace "%%Lastname%%",$_.sn `
                -replace "%%Title%%",$_.title `
                -replace "%%PhoneNumber%%",$PhoneNumber `
                -replace "%%FaxNumber%%",$SignatureCompanyFaxNumber 
                  
            $Text = $Text -replace "%%Firstname%%",$_.givenname `
                -replace "%%Lastname%%",$_.sn `
                -replace "%%Title%%",$_.title `
                -replace "%%PhoneNumber%%",$PhoneNumber `
                -replace "%%FaxNumber%%",$SignatureCompanyFaxNumber

            Set-MailboxMessageConfiguration -Identity $Mailbox.Alias -SignatureHtml $Html -AutoAddSignature $true -SignatureText $Text
        }
    }
}catch{

    Write-PPErrorEventLog -Source "Exchange Online Settings" -ClearErrorVariable

}finally{

    Remove-PSSession $s
}
Exchange Online Settings.task.config.xml
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2013-03-20T14:18:21.6393172</Date>
    <Author>Janik von Rotz (www.janikvonrotz.ch)</Author>
	<Description>Exchange Online Settings</Description>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2013-01-01T03:00:00</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe</Command>
      <Arguments>C:\Powershell-Profile\scripts\Set-EOConfig.ps1</Arguments>
      <WorkingDirectory>C:\Powershell-Profile\scripts</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

xml Google Shopping.xml

Google Shopping.xml
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0"> 
  <channel>  
    <title>Data feed Title</title>
    <link>{base_url}</link>
    <description>Data feed description.</description>
    {each type="product"}
      <item>
        <g:id>{sku}</g:id>
        <title><![CDATA[{name,[html_entity_decode]}]]></title>
        <link>{url}</link>
        <g:adwords_redirect>{url}</g:adwords_redirect>
        <g:price>{price,[number_format 2]}</g:price>
        <g:sale_price>{special_price,[number_format 2]}</g:sale_price>
        <g:online_only>y</g:online_only>
        <description><![CDATA[{short_description,[strip_tags]}]]></description>
        <g:product_type><![CDATA[{category_path}]]></g:product_type>
        <g:image_link>{image}</g:image_link>
        <g:condition>new</g:condition>
        <g:availability>in stock</g:availability>
        <g:quantity>{qty}</g:quantity>
        <g:color>{color}</g:color>
        <g:shipping_weight>{weight, [number_format 2]} kilograms</g:shipping_weight>
        <g:manufacturer>{manufacturer}</g:manufacturer>
		<g:installment>
			<g:months>{special_price,[numerototalparcelas]}</g:months>
			<g:amount>R$ {special_price,[valortotalparcelas]}</g:amount>
		</g:installment>
        <g:brand>{manufacturer}</g:brand>
        <g:mpn>{sku}</g:mpn>
        <g:gtin>{ean}</g:gtin>
      </item>
    {/each}
  </channel>
</rss>

xml Google Shopping.xml

Google Shopping.xml
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0"> 
  <channel>  
    <title>Data feed Title</title>
    <link>{base_url}</link>
    <description>Data feed description.</description>
    {each type="product"}
      <item>
        <g:id>{sku}</g:id>
        <title><![CDATA[{name,[html_entity_decode]}]]></title>
        <link>{url}</link>
        <g:adwords_redirect>{url}</g:adwords_redirect>
        <g:price>{price,[number_format 2]}</g:price>
        <g:online_only>y</g:online_only>
        <description><![CDATA[{short_description,[strip_tags]}]]></description>
        <g:product_type><![CDATA[{category_path}]]></g:product_type>
        <g:image_link>{image}</g:image_link>
        <g:condition>new</g:condition>
        <g:availability>in stock</g:availability>
        <g:quantity>{qty}</g:quantity>
        <g:color>{color}</g:color>
        <g:shipping_weight>{weight, [number_format 2]} kilograms</g:shipping_weight>
        <g:manufacturer>{manufacturer}</g:manufacturer>
  	<g:installment>
			<g:months>{price,[numerototalparcelas]}</g:months>
			<g:amount>R$ {price,[valortotalparcelas]}</g:amount>
		</g:installment>
        <g:brand>{manufacturer}</g:brand>
        <g:mpn>{sku}</g:mpn>
        <g:gtin>{ean}</g:gtin>
      </item>
    {/each}
  </channel>
</rss>

xml xml de produtos Google shoppingmodulo http://mirasvit.com/manuals/advanced-product-feeds-generator.html#ExampleFeedforGoogleShopping

xml de produtos Google shoppingmodulo http://mirasvit.com/manuals/advanced-product-feeds-generator.html#ExampleFeedforGoogleShopping

Google Shopping.xml
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0"> 
  <channel>  
    <title>Data feed Title</title>
    <link>{base_url}</link>
    <description>Data feed description.</description>
    {each type="product"}
      <item>
        <g:id>{sku}</g:id>
        <title><![CDATA[{name,[html_entity_decode]}]]></title>
        <link>{url}</link>
        <g:adwords_redirect>{url}</g:adwords_redirect>
        <g:price>{price,[number_format 2]}</g:price>
        <g:sale_price>{special_price,[number_format 2]}</g:sale_price>
        <g:online_only>y</g:online_only>
        <description><![CDATA[{short_description,[strip_tags]}]]></description>
        <g:product_type><![CDATA[{category_path}]]></g:product_type>
        <g:image_link>{image}</g:image_link>
        <g:condition>new</g:condition>
        <g:availability>in stock</g:availability>
        <g:quantity>{qty}</g:quantity>
        <g:color>{color}</g:color>
        <g:shipping_weight>{weight, [number_format 2]} kilograms</g:shipping_weight>
        <g:manufacturer>{manufacturer}</g:manufacturer>
		<g:installment>
			<g:months>{special_price,[numerototalparcelas]}</g:months>
			<g:amount>R$ {special_price,[valortotalparcelas]}</g:amount>
		</g:installment>
        <g:brand>{manufacturer}</g:brand>
        <g:mpn>{sku}</g:mpn>
        <g:gtin>{ean}</g:gtin>
      </item>
    {/each}
  </channel>
</rss>

xml CrashPlan管理员排除,位于/ Library / Application Support / CrashPlan / conf / my.service.xml中

CrashPlan管理员排除,位于/ Library / Application Support / CrashPlan / conf / my.service.xml中

gistfile1.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<config id="service" modified="2013-08-13T07:32:57:739-0500" version="4">
  <serviceBackupConfig>
    <backupConfig>
      <excludeSystem>
        <patternList>
          <pattern regex=".*/(?:42|\d{8,}).*/(?:cp|~).*"/>
          <pattern regex="(?i).*/CrashPlan.*/(?:cache|log|conf|manifest|upgrade)/.*"/>
          <pattern regex=".*\.part"/>
          <pattern regex=".*/iPhoto Library/iPod Photo Cache/.*"/>
          <pattern regex=".*\.cprestoretmp.*"/>
          <pattern regex=".*/Music/Subscription/.*"/>
          <pattern regex="(?i).*/Google/Chrome/.*cache.*"/>
          <pattern regex="(?i).*/Mozilla/Firefox/.*cache.*"/>
          <pattern regex=".*/Google/Chrome/Safe Browsing.*"/>
          <pattern regex="/Library/Application Support/CrashPlan/"/>
          <windows>
            <pattern regex=".*\$RECYCLE\.BIN/.*"/>
            <pattern regex=".*/System Volume Information/.*"/>
            <pattern regex=".*/RECYCLER/.*"/>
            <pattern regex=".*/I386.*"/>
            <pattern regex=".*/pagefile.sys"/>
            <pattern regex=".*/MSOCache.*"/>
            <pattern regex=".*UsrClass\.dat\.LOG"/>
            <pattern regex=".*UsrClass\.dat"/>
            <pattern regex=".*/Temporary Internet Files/.*"/>
            <pattern regex="(?i).*/ntuser.dat.*"/>
            <pattern regex=".*/Local Settings/Temp.*"/>
            <pattern regex=".*/AppData/Local/Temp.*"/>
            <pattern regex=".*/AppData/Temp.*"/>
            <pattern regex=".*/Windows/Temp.*"/>
            <pattern regex="(?i).*/Microsoft.*/Windows/.*\.log"/>
            <pattern regex=".*/Microsoft.*/Windows/Cookies.*"/>
            <pattern regex=".*/Microsoft.*/RecoveryStore.*"/>
            <pattern regex="(?i).:/Config\\.Msi.*"/>
            <pattern regex="(?i).*\\.rbf"/>
            <pattern regex=".*/Windows/Installer.*"/>
            <pattern regex=".*/Application Data/Application Data.*"/>
            <pattern regex="(?i).:/Config\.Msi.*"/>
            <pattern regex="(?i).*\.rbf"/>
            <pattern regex="(?i).*/Microsoft.*/Windows/.*\.edb"/>
          </windows>
          <macintosh>
            <pattern regex="/dev/.*"/>
            <pattern regex=".*\.Trash.*"/>
            <pattern regex="/\.vol/.*"/>
            <pattern regex="/mach.sym"/>
            <pattern regex="/mach_kernel"/>
            <pattern regex=".*\.hotfiles\.btree.*"/>
            <pattern regex=".*/Trash/.*"/>
            <pattern regex=".*/Network Trash Folder/.*"/>
            <pattern regex=".*/VM Storage"/>
            <pattern regex=".*\.fseventsd.*"/>
            <pattern regex=".*/Library/Caches/.*"/>
            <pattern regex=".*\.Spotlight-.*/.*"/>
            <pattern regex="/Network/.*"/>
            <pattern regex="/tmp/.*"/>
            <pattern regex="/cores/.*"/>
            <pattern regex="/afs/.*"/>
            <pattern regex="/automount/.*"/>
            <pattern regex="/private/Network/.*"/>
            <pattern regex="/private/tmp/.*"/>
            <pattern regex="/private/var/tmp/.*"/>
            <pattern regex="/private/var/folders/.*"/>
            <pattern regex="/private/var/run/.*"/>
            <pattern regex="/private/var/spool/postfix/.*"/>
            <pattern regex="/private/var/vm/.*"/>
            <pattern regex="/Previous Systems.*"/>
            <pattern regex=".*/lost\+found/.*"/>
            <pattern regex=".*/Microsoft User Data/Entourage Temp/.*"/>
            <pattern regex=".*/iP.* Software Updates/.*"/>
            <pattern regex=".*/Library/Application Support/SyncServices/.*"/>
            <pattern regex=".*/Library/Logs/.*"/>
            <pattern regex=".*/Library/Mail/Envelope Index"/>
            <pattern regex=".*/Library/Mail/AvailableFeeds/.*"/>
            <pattern regex=".*/Library/Mirrors/.*"/>
            <pattern regex=".*/Library/PubSub/Database/.*"/>
            <pattern regex=".*/Library/PubSub/Downloads/.*"/>
            <pattern regex=".*/Library/PubSub/Feeds/.*"/>
            <pattern regex=".*/Library/Safari/Icons.db"/>
            <pattern regex=".*/Library/Safari/WebpageIcons.db"/>
            <pattern regex=".*/Library/Safari/HistoryIndex.sk"/>
            <pattern regex=".*/Library/Calendars/Calendar Cache"/>
            <pattern regex=".*/iTunes/Album Artwork/Cache/.*"/>
            <pattern regex=".*/iPhoto Library/iPod Photo Cache.*"/>
            <pattern regex="(?i).*/backups.backupdb"/>
            <pattern regex="/Desktop DB"/>
            <pattern regex="/Desktop DF"/>
            <pattern regex="/Network/Servers.*"/>
            <pattern regex="/Users/Shared/SC Info.*"/>
            <pattern regex="/net/.*"/>
            <pattern regex="/private/var/automount/.*"/>
            <pattern regex="/private/var/db/dhcpclient/.*"/>
            <pattern regex="/private/var/db/fseventsd/.*"/>
            <pattern regex="/System/Library/Extensions/Caches/.*"/>
            <pattern regex=".*Mobile.*Backups/.*"/>
            <pattern regex=".*/Library/Saved Application State/.*"/>
            <pattern regex=".*/Library/Mail/.*/Info.plist"/>
            <pattern regex=".*/Library/Calendars/.*/Info.plist"/>
          </macintosh>
          <linux>
            <pattern regex="/sys/.*"/>
            <pattern regex="/dev/.*"/>
            <pattern regex="/proc/.*"/>
            <pattern regex="/tmp/.*"/>
            <pattern regex=".*/lost\+found/.*"/>
            <pattern regex="/selinux/.*"/>
          </linux>
          <solaris>
            <pattern regex="/sys/.*"/>
            <pattern regex="/dev/.*"/>
            <pattern regex="/proc/.*"/>
            <pattern regex="/tmp/.*"/>
            <pattern regex=".*/lost\+found/.*"/>
          </solaris>
        </patternList>
      </excludeSystem>
      <hostSystemExcludes locked="true">
        <patternList>
          <pattern regex=".*/(cookies|permissions).sqllite(-.{3})?"/>
          <windows/>
          <macintosh>
            <pattern regex=".*/Application Support/Google/Chrome/Default/Cookies(-journal)?"/>
            <pattern regex=".*/Library/Cookies/(Cookies.binarycookies|com.apple.appstore.plist)"/>
            <pattern regex=".*/Application Support/MobileSync/.*"/>
          </macintosh>
          <linux/>
          <solaris/>
        </patternList>
      </hostSystemExcludes>
    </backupConfig>
  </serviceBackupConfig>
</config>

xml PowerShell:通过ActiveDirectory组成员身份设置Office365许可证<br/> #ActiveDirectory <br/> #PowerShell <br/>#Office365

PowerShell:通过ActiveDirectory组成员身份设置Office365许可证<br/> #ActiveDirectory <br/> #PowerShell <br/>#Office365

Set-O365UserLicensesByADGroup.ps1
<#
$Metadata = @{
    Title = "Set Office365 Licenses by ActiveDirectory Group Membership"
    Filename = "Set-O365UserLicensesByADGroup.ps1"
    Description = @"
Adding license to a Office365 user as long the user is in the correct ActiveDirectory group
or in the white list, the users is active, the user has a mailbox.
The script will remove inactive licenses or if necessary replace them.
"@
    Tags = "powershell, activedirectory, office365, user, license, activation"
    Project = ""
    Author = "Janik von Rotz"
    AuthorContact = "http://janikvonrotz.ch"
    CreateDate = "2013-08-13"
    LastEditDate = "2014-05-02"
    Url = "https://gist.github.com/janikvonrotz/6218401"
    Version = "3.5.0"
    License = @'
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Switzerland License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ch/ or
send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
'@
}
#>

try{

    #--------------------------------------------------#
    # settings
    #--------------------------------------------------#
    $UsageLocation = "CH"

    <#
    Name: name of the license configuration, has to be unique
    ADGroupSID: Active Directory group containing the users to apply a license
    Users: for office 365 only users or selected domain users
    License: Office 365 license type
    DisabledPlans: Plans to disable
    Priority: if a user is in both groups the license with the higher priority will be applied
    SecondaryLicenses: in case the license is not available but another is also pssible to add you can add the name of this license configuration here
    Count: counting the number of licenses
    #>

    $LicenseConfig = $(New-Object PSObject -Property @{
        Name = "SharePoint Online Plan 1"
        License = "vbluzern:SHAREPOINTSTANDARD"
        ADGroupSID = "S-1-5-21-1744926098-708661255-2033415169-37562" # SPO_SharePointOnlinePlan1License
        Priority = 3
        SecondaryLicense = "Enterprise Plan 1 - SharePoint Only"
    }), 
    $(New-Object PSObject -Property @{
        Name = "Enterprise Plan 1"
        License = "vbluzern:STANDARDPACK"
        ADGroupSID = "S-1-5-21-1744926098-708661255-2033415169-36657" # SPO_365E1License
        Priority = 2  
    }),
    $(New-Object PSObject -Property @{
        Name = "Enterprise Plan 1 - SharePoint Only"
        License = "vbluzern:STANDARDPACK"
        DisabledPlans = "EXCHANGE_S_STANDARD"
    }),
    $(New-Object PSObject -Property @{
        Name = "Enterprise Plan 1 - O365 users only"
        Users = "admin@vbluzern.onmicrosoft.com"
        License = "vbluzern:STANDARDPACK"
    }),
    $(New-Object PSObject -Property @{
        Name = "SharePoint Online Plan 1 - O365 users only"
        Users = "urs.egli@vbluzern.onmicrosoft.com","innotix@vbluzern.onmicrosoft.com"
        License = "vbluzern:SHAREPOINTSTANDARD"
    })

    #--------------------------------------------------#
    # modules
    #--------------------------------------------------#
    Import-Module MSOnline
    Import-Module MSOnlineExtended
    Import-Module ActiveDirectory

    #--------------------------------------------------#
    # main
    #--------------------------------------------------#
    $Credential = Import-PSCredential $(Get-ChildItem -Path $PSconfigs.Path -Filter "Office365.credentials.config.xml" -Recurse).FullName
    Connect-MsolService -Credential $Credential

    # normalize license config
    $LicenseAndUser = $LicenseConfig | select @{L="Name";E={$_.Name}}, 
        @{L="UserPrincipalName"; E={$_.UserPrincipalName}},
        @{L="ADGroupSID";E={$_.ADGroupSID}},
        @{L="Users";E={$_.Users}},
        @{L="License";E={$_.License}},
        @{L="DisabledPlans";E={if($_.DisabledPlans){$_.DisabledPlans = New-MsolLicenseOptions -AccountSkuId $_.License -DisabledPlans $_.DisabledPlans}}},
        @{L="Priority";E={$_.Priority}},
        @{L="SecondaryLicense";E={$_.SecondaryLicense}}

    # extend the secondary license field with the normalized object
    $LicenseAndUser = $LicenseAndUser | Foreach-Object{
        New-TreeObjectArray -Array $LicenseAndUser -Objects $_ -Attribute "SecondaryLicense" -Filter "Name"
    }

    # get userprincipalnames of the ad group members 
    $LicenseAndUser = $LicenseAndUser | Foreach-Object{   

        if($_.ADGroupSID){

            $License = $_

            Get-ADGroupMember $_.ADGroupSID -Recursive | Get-ADUser | where{$_.Enabled -eq $true} | Foreach-Object{
            
                $UserLicense = $License.psobject.Copy()
                $UserLicense.UserPrincipalName = $_.UserPrincipalName
                $UserLicense
            }
        }

        if($_.Users){

            $License = $_

            $_.Users | Foreach-Object{

                $UserLicense = $License.psobject.Copy()
                $UserLicense.UserPrincipalName  = $_
                $UserLicense
            }
        }
    }

    $Report = @()
    function New-ReportItem{

        param(
            $User,
            $License,
            $Status # NoChanges, NotAllowed, LicenseAssigned, SecondaryLicenseAssigned, UnableToAssignLicense, LicenseRemoved, UnableToRemoveLicense, LicenseReplaced, UnableToReplaceLicense
        )

        
        Return $(New-Object PSObject -Property @{
            User = $User
            License = $License
            Status = $Status
        })

    }
    
    $MsolUsers = Get-MsolUser -All
    $MsolUsers | Foreach-Object{

        $User = $_

        # debug a user, set debugger on $true variable
        if($User.UserPrincipalName -eq ""){
        $true}

        # get license configuration for this user
        $Config = $LicenseAndUser | where{$_.UserPrincipalName -eq $User.UserPrincipalName}

        # check the license configuration with the higher priority
        if($Config.count -gt 1){
            $Config = $Config | sort Priority | select -First 1
        }

        # apply the license

        if($Config){
        
            # licenses are not same

            if($User.IsLicensed -and ($User.Licenses.AccountSkuId -ne $Config.License)){

                # remove license    
                $User.Licenses | Foreach-Object{ 
                
                    $License = $_               
                    
                    try{
                        Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -RemoveLicenses $License.AccountSkuId -ErrorAction Stop                        
                    }catch{
                        Write-PPErrorEventLog -Message "Could not remove license: $($License.AccountSkuId) to user: $($User.UserPrincipalName)" -Source "Office365 License Management" -ClearErrorVariable                   
                    }
                }

                # Assign license
                try{
                    Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -AddLicenses $Config.License -LicenseOptions $Config.DisabledPlans -ErrorAction Stop
                    Write-PPEventLog "Replacee Office365 license: $($User.Licenses.AccountSkuId) with: $($Config.License) for user: $($User.UserPrincipalName)" -Source "Office365 License Management" -WriteMessage
                    $Report += New-ReportItem -User $User.UserPrincipalName -License $Config.License -Status "LicenseReplaced"
                }catch{
                    Write-PPErrorEventLog -Message "Could not assign license: $($Config.License) to user: $($User.UserPrincipalName)" -Source "Office365 License Management" -ClearErrorVariable
                    $Report += New-ReportItem -User $User.UserPrincipalName -License $Config.License -Status "UnableToReplaceLicense"
                }
    
            # correct license already applied

            }elseif($User.IsLicensed){

                Write-Host "User: $($User.UserPrincipalName) is already licensed with: $($Config.License)"
                $Report += New-ReportItem -User $User.UserPrincipalName -License $Config.License -Status "NoChanges"

            # apply a license

            }else{
                
                # set location in order to apply a license               
                Set-MsolUser -UserPrincipalName $User.UserPrincipalName -UsageLocation $UsageLocation

                # apply license
                try{
                    Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -AddLicenses $Config.License -LicenseOptions $Config.DisabledPlans -ErrorAction Stop
                    Write-PPEventLog "Set Office365 license: $($Config.License) for user: $($User.UserPrincipalName)" -Source "Office365 License Management" -WriteMessage
                    $Report += New-ReportItem -User $User.UserPrincipalName -License $Config.License -Status "LicenseAssigned"
                }catch{
                    Write-PPErrorEventLog -Message "Could not assign license: $($Config.License) to user: $($User.UserPrincipalName)" -Source "Office365 License Management" -ClearErrorVariable
                    $Report += New-ReportItem -User $User.UserPrincipalName -License $Config.License -Status "UnableToAssignLicense"
                }
            }

        # ignore the user or remove the license

        }else{

            # remove the license

            if($User.IsLicensed){
                            
                $User.Licenses | Foreach-Object{
                
                    $License = $_

                    try{
                        Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -RemoveLicenses $License.AccountSkuId
                        Write-PPEventLog "Removed Office365 license: $($License.AccountSkuId) from user: $($User.UserPrincipalName)" -Source "Office365 License Management" -WriteMessage
                        $Report += New-ReportItem -User $User.UserPrincipalName -License $License.AccountSkuId -Status "LicenseRemoved"
                    }catch{
                        Write-PPErrorEventLog -Message "Could not remove license: $($License.AccountSkuId) to user: $($User.UserPrincipalName)" -Source "Office365 License Management" -ClearErrorVariable
                        $Report += New-ReportItem -User $User.UserPrincipalName -License $License.AccountSkuId -Status "UnableToRemoveLicense"
                    }
                    
                }

            # ignore the user

            }else{

                Write-Host "User: $($User.UserPrincipalName) is not allowed"
                $Report += New-ReportItem -User $User.UserPrincipalName -Status "NotAllowed"
            }
        }
    }

    $Report | Group-Object Status

}catch{
    
    Write-PPErrorEventLog -Source "Office365 License Management" -ClearErrorVariable -Message
}
Office365 License Management.task.config.xml
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2013-03-20T14:18:21.6393172</Date>
    <Author>Janik von Rotz (www.janikvonrotz.ch)</Author>
	<Description>Office365 License Management</Description>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2013-01-01T02:30:00</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe</Command>
      <Arguments>C:\Powershell-Profile\scripts\Set-O365UserLicensesByADGroup.ps1</Arguments>
      <WorkingDirectory>C:\Powershell-Profile\scripts</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

xml Blogger.com小工具

Blogger.com小工具

blogger_widget.xml
  <!--  Инициация загрузки виджета-->  
  <b:widget id='HTML3' locked='false' title='' type='HTML'>
    <b:includable id='main'>
  <!-- only display title if it's non-empty -->
        <b:if cond='data:title != &quot;&quot;'>
          <h4 class='title'><data:title/></h4>
        </b:if>
                    <div class='widget-content'>
                      <data:content/>
                    </div>

          <b:include name='quickedit'/>
      </b:includable>
  </b:widget>

xml PowerShell:发送密码过期提醒#PowerShell#ActiveDirectory

PowerShell:发送密码过期提醒#PowerShell#ActiveDirectory

Send-PasswordExpirationReminder.ps1
<#
$Metadata = @{
	Title = "Send Password Expiration Reminder"
	Filename = "Send-PasswordExpirationReminder.ps1"
	Description = ""
	Tags = "powershell, script, jobs"
	Project = ""
	Author = "Janik von Rotz"
	AuthorContact = "http://.janikvonrotz.ch"
	CreateDate = "2013-08-08"
	LastEditDate = "2013-11-25"
	Version = "2.1.0"
	License = @'
This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or
send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
'@
}
#>

try{

    #--------------------------------------------------#
    # modules
    #--------------------------------------------------#    
    Import-Module ActiveDirectory
	
    #--------------------------------------------------#
    # settings
    #--------------------------------------------------#   
    $TriggerDays = 25, 10, 5, 1
    $SendLinkOnDays = 25,10, 5, 1
	$DaysBeforeDisablingUsersWithPasswordNeverExpires = 180
	$ADGroup = "S-1-5-21-1744926098-708661255-2033415169-36648" # Memberof GroupName should be "SPO_PasswordNotification"   
    
    #--------------------------------------------------#
    # main
    #--------------------------------------------------#

    # get mail config         
    $Mail = Get-PPConfiguration $PSconfigs.Mail.Filter | %{$_.Content.Mail | where{$_.Name -eq "PasswordReminder"}} | select -first 1

    # get days until password expires
    $MaxDays = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge.Days 
    if($MaxDays -le 0){throw "Domain 'MaximumPasswordAge' password policy is not configured."}

    # Set days when an email should be sent to inform the users
    $TriggerDays = 25, 10, 5, 1
    $SendLinkOnDays = 25,10, 5, 1

    foreach($TriggerDay in $TriggerDays){    
    
        # Memberof GroupName should be "SPO_PasswordNotification"       
        Get-ADGroupMember $ADGroup -Recursive | 
        Get-ADUser -Properties Enabled, lastLogonTimestamp, PasswordNeverExpires, PasswordLastSet, Mail, DisplayName |
        Select *, @{L = "PasswordExpires";E = { 
            if($_.PasswordNeverExpires){
                $DaysBeforeDisablingUsersWithPasswordNeverExpires - ((Get-Date) - ($_.PasswordLastSet)).Days
            }else{
                $MaxDays - ((Get-Date) - ($_.PasswordLastSet)).Days
            }
        }} |
        where{($_.Enabled -eq $true) -and ($_.PasswordExpires -eq $TriggerDay)} | %{ 
                              
            # set subject
            $Subject = "Passwort Erinnerung: $($_.DisplayName) ihr Passwort läuft in $($_.PasswordExpires) Tagen ab"
            
            $BodyFont = "font-size: 11pt; font-family: Calibri"
            
            # create mail message
            $Body = "<p style = ""$BodyFont"">Guten Tag $($_.DisplayName) <br/> <br/> Ihr Passwort läuft am $(Get-Date (Get-Date).AddDays($_.PasswordExpires) -Format D) ab.</b></p>"          
            if($SendLinkOnDays -contains $TriggerDay){            
                $Body += "<p style = ""$BodyFont"">Bitte ändern Sie das Passwort bevor es abläuft. Rufen Sie dazu die folgende Seite auf: <a href=""https://vbluzern.sharepoint.com/Support/SitePages/Passwortwechsel.aspx"" target=""_blank"">Link</a></p>"
            }
             $Body += "<p style = ""$BodyFont"">ACHTUNG! Dieses E-Mail wurde von einem unbeaufsichtigtem Konto verschickt, Antworten an den Sender dieser E-Mail werden nicht bearbeitet.</p>"

            # send mail
            Write-PPEventLog "$($MyInvocation.InvocationName)`n`nSend password reminder to $($_.Mail)" -WriteMessage -Source "Send Password Expiration Reminder" 
            Send-MailMessage -To $_.Mail -From $mail.FromAddress -Subject $Subject -Body $Body -SmtpServer $Mail.OutSmtpServer -BodyAsHtml -Priority High -Encoding ([System.Text.Encoding]::UTF8)
        
        }        
    }
   
}catch{

	Write-PPErrorEventLog -Source "Send Password Expiration Reminder" -ClearErrorVariable
}
ActiveDirectory.mail.config.xml
<?xml version="1.0" encoding="utf-8"?>
<Content>

	<Metadata>
		<Title>PowerShell Profile Mail Configuration</Title>
		<Filename>DirSync.mail.config.xml</Filename>
		<Description></Description>
		<Tags>powershell, profile, mail, configuration</Tags>
		<Project></Project>
		<Author>Janik von Rotz</Author>
		<AuthorContact>http://janikvonrotz.ch</AuthorContact>
		<CreateDate>2013-08-14</CreateDate>
		<LastEditDate>2013-08-14</LastEditDate>
		<Version>1.0.0</Version>
	</Metadata>
	
	<Mail Name="ErrorReport" OutSmtpServer="vblw2k8mail05"	FromAddress="noreply@sharepoint.vbl.ch"	ReplyToaddress=""></Mail>
	<Mail Name="PasswordReminder" OutSmtpServer="vblw2k8mail05"	FromAddress="noreply@vbl.ch"	ReplyToaddress=""></Mail>

</Content>

xml Theme.AppCompat.Light.NoActionBar

Theme.AppCompat.Light.NoActionBar

styles_noactionbar.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light">
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item> <!-- For 2.x version  -->
  </style>

</resources>

xml Theme.AppCompat.Light.NoActionBar

Theme.AppCompat.Light.NoActionBar

styles_noactionbar.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light">
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item> <!-- For 2.x version  -->
  </style>

</resources>