Windows PowerShell
The space to share experiences, engage and learn from experts.
4,694 Members

Windows PowerShell Spaces

Latest Activity

  • , 02-01-2017

    Looking for a way to update the features for our E3 licensed users. Setting them initially is no problem but we have not found a way to update someone that already has an E3.


    So user A has an E3 but only  the "SharePoint Online" feature on and we need 5 o

    ... Read More
    3 Replies
    , 02-18-2017

    I'm not sure if you managed to solve this, but I wrote a couple powershell functions that might help. I wasn't having a good time trying to re-assign licenses to users as we don't enable all features of a license. I found it easier to just remove all the licenses and re-assign them. that way I knew exactly which licenses they had. 


    The first is a function to clear the license for the user and the second function clears the licenses and then assigns the specific licenses, with the options that we chose. I hope it helps!


    # Removes all O365 Licenses
    # Accepts UPN
    # Returns Nothing
    function Remove-O365Licenses ($upn)
    # Get user info from O365
    $userInfo = Get-MsolUser -UserPrincipalName $upn

    # Clear any existing licenses
    if ($userInfo.isLicensed -eq $true)
    foreach ($sku in ($userInfo | select -ExpandProperty licenses))
    #Write-Host "Removing License: " $sku.AccountSkuId
    Set-MsolUserLicense -UserPrincipalName $upn -RemoveLicenses $sku.AccountSkuId


    # Clears previous license and sets correct Office 365 Staff license
    # Accepts UPN
    # Returns nothing
    function Set-O365StaffLicense ($upn)
    # Set SKU options for staff
    $O365SkuStaff1 = New-MSOLLicenseOptions -AccountSkuID "lethsd51:PROJECTONLINE_PLAN_1_FACULTY" -DisabledPlans SHAREPOINTWAC_EDU
    $O365SkuStaff3 = New-MSOLLicenseOptions -AccountSkuID "lethsd51:OFFICESUBSCRIPTION_FACULTY" -DisabledPlans SWAY,SHAREPOINTWAC_EDU

    # Get user info from O365
    $userInfo = Get-MsolUser -UserPrincipalName $upn

    Write-Host "Processing $upn"
    # Set usage location
    if ($userInfo.UsageLocation -eq $null)
    Set-MsolUser -UserPrincipalName $upn -UsageLocation CA

    # Remove All Current Licenses
    Remove-O365Licenses ($upn)

    # Apply licenses. The order of these matter!
    Write-Host "Setting License: Project Online for Faculty"
    Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses lethsd51:PROJECTONLINE_PLAN_1_FACULTY -LicenseOptions $O365SkuStaff1
    Write-Host "Setting License: Office 365 Education for Faculty"
    Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses lethsd51:STANDARDWOFFPACK_FACULTY -LicenseOptions $O365SkuStaff2
    Write-Host "Setting License: Office 365 ProPlus for Faculty"
    Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses lethsd51:OFFICESUBSCRIPTION_FACULTY -LicenseOptions $O365SkuStaff3
    Write-Host "Setting License: Exchange Online Plan 2 for Faculty"
    Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses lethsd51:EXCHANGEENTERPRISE_FACULTY




  • , 02-06-2017

    I have a litte problem. I'm migrating OneDrives between Office 365 tenants. In the receiving end they require that all documents have a major version. In the orginating end there are a few users that have turned on Minor versions i the versioning settings

    ... Read More
    2 Replies
    , 02-07-2017


    Here is my final function:

    Function Checkin-Allfiles {
                This function checks performs a CheckOut/CheckIn on files in order to elevate the files to Major Version.
                This function checks performs a CheckOut/CheckIn on files in order to elevate the files to Major Version.
                It requires the Office Dev PnP module SharePointPnPPowerShellOnline to be loaded at runtime. 
                .PARAMETER LibraryUrl
                Specifies url of the site collection
                .PARAMETER Folder
                Specifies the Root Folder to check in files from
                Checkin-Allfiles -LibraryUrl -Folder Documents 
                This gets all files in the documents folder and all subfolders, and checks in a new major version of all files 
                Checkin-Allfiles -LibraryUrl -Folder Documents/subfolder 
                This This gets all files in the Subfolder folder and all subfolders, and checks in a new major version of all files 
        param (
            [Parameter (position = 0,HelpMessage = 'The Document Library URL', Mandatory = $TRUE)]
            [Parameter (position = 1,HelpMessage = 'The Folder Site Relative URL (Documents)', Mandatory = $TRUE)]
        Write-Verbose -Message "Connecting to $LibraryUrl"
        Connect-PnPOnline -Credentials (get-credential) -url $LibraryUrl
        Write-Verbose -Message "Getting the files in $Folder" 
        $files = Find-PnPFile -Folder $Folder -Match * -Verbose
        Write-Verbose -Message 'Done getting files'
        foreach ($file in $files) {
            Write-Verbose -Message "Checking out $($file.ServerRelativeUrl)"
            Set-PnPFileCheckedOut -Url $file.ServerRelativeUrl 
            Write-Verbose -Message "Checking in $($file.ServerRelativeUrl)"
            Set-PnPFileCheckedIn -Url $file.ServerRelativeUrl -CheckinType MajorCheckIn -Comment 'Checked In with Script to raise version to major' 
  • , 11-21-2016

    If you search for "PowerShell Cheat Sheet" in Duck Duck Go, you get a really great reference for all sorts of syntax/operators/if/loops/etc.



    Read More
    1 Reply
    , 01-30-2017
  • , 12-16-2016

    The name of this tech community space should be just "PowerShell".


    I presume the MS Tech Community creators copied "Windows PowerShell" from an existing forum name. The name of the product is/was "Windows PowerShell". But PowerShell 6 is cross-platform, a

    ... Read More
    2 Replies
    , 01-30-2017
    I think that is a great idea unless they plan to create another space by platform, for example "Powershell on Linux".
  • , 01-23-2017

    Hello evry one 

     i have some problem

    i create 2 groupe in yammer and want to  administer some right using csv and powershell

     ican i do? any one have some idea?


    0 Reply
Windows PowerShell Announcements
Welcome to the Windows PowerShell Community! This is the place discuss best practices, news, and the latest trends and topics related to Windows PowerShell. Third party promotional content will be deleted. Thanks for your help keeping this community a vibrant and useful place!