Tag: from

  • Migrate Office365 Photos to AD

    Many of my customers have Office365 and have been using Skype for Business for sometime now. It is likely that your organization users have uploaded their profile picture. Now only if there was a way to sync those pictures back to your AD – so it looks neat & nice. There is a way!

    #MigrateOffice365PhotosToAD.ps1
    
    function Get-Office365Photo($EmailAddress,$Credential) {
        $wc = New-Object System.Net.WebClient
        $wc.credentials = $Credential
        # Build the URL that'll return the jpeg of the user's photo
        $url = "https://outlook.office365.com/ews/exchange.asmx/s/GetUserPhoto?email=$EmailAddress&size=HR96x96"
        # Build a path to export it to (.\[email protected])
        $outPath = "$pwd\$EmailAddress.jpg"
        try { 
            # Download the image and save it to the current directory
            $wc.DownloadFile($url,$outPath)
            return $outPath
        } catch { throw $_ }
    }
    
    function Upload-ADPhoto($Username,$FilePath) {
        # Import the photo into a variable as a byte array
        $photo = [byte[]](Get-Content $FilePath -Encoding byte)
        # Replace the current value of thumbnailPhoto with the byte array from above
        Set-ADUser $Username -Replace @{ThumbnailPhoto=$photo}
    }
    
    # Get the credential to allow us to download the images
    $Cred = Get-Credential -Message "Please enter your Office 365 Credentials"
    
    # Get every mail-enabled AD user
    $users = Get-ADUser -ldapfilter '(mail=*)' -properties mail
    
    # For each of the mail-enabled users...
    foreach ($user in $users) {
        try {
            # Download the photo
            $photoPath = Get-Office365Photo -EmailAddress $user.mail -Credential $Cred
            # Upload the photo
            Upload-ADPhoto -Username $user -FilePath $photoPath
        } catch {
            Write-Warning "Unable to update image for $($user.mail)"
        }
    }

    Source

  • Quick and Simple Way to Export DHCP Scope Settings From One Server to Another

    Applies to:

    Windows Server 2008 R2, Windows Server 2012R2, Windows Server 2016

    From the command prompt on the source DHCP server run the following command:

    netsh dhcp server export c:\dhcp.dat all
    

    2.  Copy the “dhcp.dat” file to the new, or destination, DHCP server and run the following command:

    netsh dhcp server import c:\dhcp.dat all

    While running the export command, the DHCP service will be temporarily stopped and won’t respond to DHCP requests.  Also, the import will fail if there are any existing DHCP scopes that overlap with the original DHCP servers configuration.

  • Exporting Site List from IIS 7.x

    1. Open up command prompt
    2. Type: %windir%\system32\inetsrv\appcmd list site > c:\sites.csv
    3. Open the Sites.csv file in Excel!