Blog

  • Convert resource mailbox to a user mailbox

    Based on my audit for a client I found that a user mailbox was at sometime converted to a resource mailbox. There is no convert button/ link to switch it back. I still don’t know how, or why this would have happened.

    Anyways, for someone who may come across this weird issue, here is the fix for it.

    Set-Mailbox [email protected] -Type Regular

    This will convert it from a shared mailbox, or a resource mailbox to a user mailbox.

  • Find out ‘in cloud’ Distribution Groups

    Microsoft Teams was announced yesterday and many want to jump right in. I noticed when users wanted to create teams, new distribution groups started getting added. I wanted to find out my ‘In cloud’ distribution groups and was surprised there was no property for the item.

    633466

     

    I was able to find out the groups using the following:

    Get-MsolGroup -All | where {$_.lastdirsynctime -eq $null}

    This listed the information I needed to clean up groups.

    You may also want to disable ‘group creation’ for users. Read how to do that here.

     

  • 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

  • Create a Virtual Machine with 2 NICs in Azure Classic

    Create a Virtual Machine with 2 NICs in Azure Classic

    Unfortunately, in Azure you cannot create a Virtual Machine in the GUI with 2 Network Cards. You cannot even add a 2nd NIC to a VM once it has been created. The only way to create a VM with 2, is to specify the additional NIC’s at the time of creation and ONLY via powershell. I have compiled a Powershell script that will do this. I have also listed the commands next to each comment to get the value to put there. Copy the code below into a PS1 and launch it from a PowerShell window.

    ############## Change Values Below Here #############
    
    # Set Subscription that will be used. Get-AzureSubscription
    $subscr="Free Trial"
    
    # Cloud Service Name. Get-AzureService
    $svcname="Cloud Service"
    
    #Set Storage Account VM will be created in. Get-AzureStorageAccount
    $staccount="Storage01"
    
    # Name of the VM Provisioned
    $vmname="VM01"
    
    # Instance Size of the VM required
    $vmsize="Standard_DS2_v2"
    
    # Virtual Network Name. Get-AzureVNetConfig
    $vnetname="Virtual Network"
    
    # OS you want to Deploy
    # 2012 = "Windows Server 2012 R2 Datacenter"
    # 2008 = "Windows Server 2008 R2 SP1"
    
    $OSversion = "Windows Server 2008 R2 SP1"
    
    # vNic1 IP Address
    $vNic1IP = "10.0.2.11"
    $vNic1Subnet = "Live"
    
    # vNic2 IP Address
    $vNic2Name = "Replication"
    $vNic2IP = "10.0.1.11"
    $vNic2Subnet = "Replication"
    
    ############# DO NOT CHANGE VALUES BELOW HERE ############
    
    # Select Subscription and Storage
    Set-AzureSubscription -SubscriptionName $subscr -CurrentStorageAccountName $staccount
    
    # Get image for VM
    $image = Get-AzureVMImage `
    | where{$_.ImageFamily -eq $OSversion} `
    | sort PublishedDate -Descending `
    | select -ExpandProperty ImageName -First 1
    
    # Creates a new VM config with the VM name, its Size and the Image Used
    $vm1 = New-AzureVMConfig -Name $vmname -InstanceSize $vmsize `
    -Image $image
    
    # Asks you for the admin username and password for the machine
    
    $cred=Get-Credential -Message "Type the name and password of the local administrator account."
    $vm1 | Add-AzureProvisioningConfig -Windows -AdminUsername $cred.Username -Password $cred.GetNetworkCredential().Password
    
    ###### 2nd Network Card - Remove comments on next 2 lines if you need a 2nd NIC #
    
    #Add-AzureNetworkInterfaceConfig -Name $vNic2Name `
    # -SubnetName $vNic2Subnet -StaticVNetIPAddress $vNic2IP -VM $vm1
    
    # Create vNic1 - Will be the Default Gateway so assign to Correct Subnet
    Set-AzureSubnet -SubnetNames $vNic1Subnet -VM $vm1
    Set-AzureStaticVNetIP -IPAddress $vNic1IP -VM $vm1
    
    New-AzureVM -ServiceName $svcname –VNetName $vnetname –VMs $vm1
  • Active Directory: Changing passwords for users in bulk using a .csv file

    Many accounts in your AD might need a password change. What if you want to do this in bulk ?

    First, we need to the userlist. Depending on your requirements we need to get a list of users (specifically samaccountname). For random password generation I recommend using http://manytools.org/network/password-generator/ as it can generate up 1000 for free.

    Here is what my UserList.csv look like:

    sAMAccountName,Password
    test1,gqLfZub$OtO#dBg
    test2,6eXq78gTyx$YjmM
    test3,ZNgl!KdYo7U6yzR
    test4,voiIs!TISw!Wcyc
    test5,W7ZBTAe7CWcFzyn
    test6,BykgCY5b*NGFO5!
    test7,3ApLlchwgRQwf1P
    test8,9jZvvR2$wDggf3M
    test9,*QCDjcgnNLkBDP1
    test10,sZpvUnvjJxAE9HE
    test11,$C8TX!tcS3d#MjK
    test12,Pzw*aH6zjpOx8Wj
    test13,XmfIPiIz82!!X77
    test14,ri!!hQX!w!FSZuI
    test15,S0Gzf6fEUsG!4Ib
    test16,Kj8s!vy94S!ozLJ
    test17,PzFzjP7obALeuWa
    test18,Ri5V2laxxck6Rgg
    test19,Rw8KcX*FoMT#gr1
    test20,QDndAgzdYo5CYX!

    Make sure you do the following on a domain controller or connecting to your domain controller via PS-remote with elevated permissions.

    Run this in PowerShell (Open PowerShell in Admin Mode)

    PowerShell:

    Import-Module Active Directory
    $Resetpassword = Import-Csv "c:\_Scripts\UserList.csv"
    
    foreach ($Account in $Resetpassword) {
        $Account.sAMAccountName
        $Account.Password
            Set-ADAccountPassword -Identity $Account.sAMAccountName -NewPassword (ConvertTo-SecureString $Account.Password -AsPlainText -force) -Reset
    }

    [su_note note_color=”#fafae8″]-Reset
    Specifies to reset the password on an account. (User is not prompted to change password).
    To use this parameter, you must set the -NewPassword parameter.
    You do not need to specify the -OldPassword parameter.
    [/su_note]

  • Extending the Booking days for Conference Room Calendar (Resource)

    By default Office365 limits Resource booking days to just 180 days. The maximum days it can be booked for 1080 days.

    I like to make resource booking days 1 year from the day of making the reservation/ appointment. Now instead of visiting each calendar and making the change, powershell can help us out.

    #Connect to Office365 
    $cred = Get-Credential
    Import-Module MSOnline
    Connect-MsolService -Credential $cred
    $s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection
    $importresults = Import-PSSession $s
    
    #Get all the Rooms and make the booking days to 365
    Get-MailBox | Where {$_.ResourceType -eq "Room"} | Set-CalendarProcessing -BookingWindowInDays 365

    Happy Booking!

  • Linux: CentOS 6 kernel panic+0xa7/0x16f fix

    Linux: CentOS 6 kernel panic+0xa7/0x16f fix

    So ran into a view issue for a Linux Host today. Kernel Panic !!!

    There could be a number of reasons that you might get this error. The three common reasons may be:

    1. There was a change to selinux config – (that might be an error in the config file)
    2. There are disk errors
    3. The kernel is corrupted

    None of the kernels in the GRUB boot menu will boot, you get a kernel panic:

    1-kernel-panic

    Kernel panic – not syncing: Attempted to kill init!
    Pid: 1, comm: init Not tainted 2.6.32-504.3.3.el6.x86_64 #1
    panic+0xa7/0x16f
    do_exit+0x862/0x870
    fput+0x25/0x30
    do_group_exit+0x58/0xd0
    sys_exit_group+0x17/0x20
    system_call_fastpath+0x16/0x1b

    Booting in single user mode doesn’t work either.

    Here’s how to fix this:

              1. Reboot, and go in the GRUB menu. You have 3 seconds to strike the arrow keys before it will automatically boot the default kernel.2-grub-menu
              2. Select the first line, the default kernel, and press the E key on the keyboard to edit the parameters. You will then see the following.
                3-grub-edit
              3. Use the arrow keys to select the 2nd line, that starts with kernel. Press the E key to change this line, use the arrow keys to go to the end and type a space followed by enforcing=0
                4-grub-edit
              4. Press enter to conform and then press B to boot the system.
                It should boot up fine now.
              5. Choose your solution:

                [su_tabs vertical=”yes”]
                [su_tab title=”SELINUX Config File”]

                Disabled for the SELINUXTYPE variable, that’s wrong it has to be for the SELINUX variable. In the screenshot below I show you the correct settings in the config file to disable SELINUX.

                5-selinux-disabled

                [/su_tab]
                [su_tab title=”Disk Errors”]

                fsck -a /dev/sda1

                [/su_tab]

                [su_tab title=”Rebuild Kernel”]

                yum remove kernel
                yum-complete-transaction
                yum update

                [/su_tab]
                [/su_tabs]

              6. Reboot.
  • VMware: Intermittent Error: Unexpected character ‘’ (code 65279 / 0xfeff) in prolog; expected ‘<' at [row,col {unknown-source}]: [1,1] pop up in Windows vSphere client ?

    Recently, I got the error below when using the vSphere client.

    Problem:

    error

    I have only tested this solution on:

    2016-10-04_11-41-47

    Solution:

    Repair your installation of Microsoft Visual J#® 2.0 Redistributable Package – Second Edition (x64)

    Download

    The error went away after repair.

    In trying to google the error some user have reported that uninstall the patch KB3147458 worked for them. I didn’t have the patch.

     wusa.exe /uninstall /KB:3142024

    Hope this helps.

  • Windows: Hide Internet Explorer 11 address bar & navigation bar

    Windows: Hide Internet Explorer 11 address bar & navigation bar

    Applies to:

    Windows Server 2008R2, Windows Server 2012R2, Windows 10

    There are two ways this can be accomplished depending on your needs for the controlled environment.

    GPO:

    I would like to first clarify that there is not a single GPO to just hide TABS in IE11. There is however a way you can enforce IE in Full View Mode which by default will remove the TABS and Address bar via a GPO.

    The GPO  you can use to enforce the Full-Screen view is available on both Computer and User configuration policy. Below is the gpo location path in group policy editor console.

    • GPO NAME: Enforce full-screen mode
    • LOCATION: Computer or User configuration – Computer Configuration\Administrative Templates\Windows Components\Internet Explorer
    • KEY LOCATION: Software\Policies\Microsoft\Internet Explorer\Toolbars\Restrictions

    SCREENSHOT: GPO CONSOLE

    2352.GPO-LOCATION

    WINDOWS REGISTRY:

    This will cause the IE address bar to not show. I disabled the Navigation bars too so it gives a clean window experience.

    SCREENSHOT: REGISTRY LOCATION WITH VALUES

    1172.GPO-REGISTRY-LOCATION

    Download the Registry file.

    The GPO and keys will cause the browser to open in full view with no address bar or tabs

    7536.FULL-VIEW-AFTER-GPO

  • Excel: Check email addresses in bulk if format is correct or not

    So had a request today to clean up email addresses as some of them were not valid. This was needed for over 1500 email addresses.

    So used the formula below and was able to find all addresses that were “FALSE”. I filtered them out and was able to fix them as needed.

    Here’s what you need to do:

    If your e-mails are in A column, go in the B column and in the B1 cell and copy paste this code:

    =AND(FIND("@";B2);FIND(".";B2);ISERROR(FIND(" ";B2)))

    Then, go down and left on the B1 cell so you can copy and paste the code to the other cells.  For all the valid e-mails, it will give you ‘TRUE’ and for the invalid ‘FALSE’.

    2016-08-25_14-34-49