Lync Online – Add company name to lync contact card

To add Company name to lync contact card, run this in powershell

$User = "xxxxxxxxx"
$PWord = Read-Host 'What is your password?' -AsSecureString
$cred = New-Object –TypeName System.Management.Automation.PSCredential  –ArgumentList $User, $PWord
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection
$importresults = Import-PSSession $s

get-user | Set-User -Company "COMPANYNAME"

get-user | ft name, Company

VN:F [1.9.22_1171]
Rating: 0.0/6 (0 votes cast)

PowerShell: Change Automatic Start Action on Hyper-V VM`s

To easy change Automatic Start Action on all runnings VM´s on your Hyper-V server run this command:

Get-VM | Where { $_.State –eq ‘Running’ } | Set-VM -AutomaticStartAction StartIfRunning

To validate it run this command:

Get-VM | Where { $_.State –eq ‘Running’ } | ft Name, AutomaticStartAction -AutoSize
VN:F [1.9.22_1171]
Rating: 0.0/6 (0 votes cast)

Monitor Citrix Licenses In Use With Powershell

# Setup Variables
$Total = 0
$InUse = 0
$StrHost = "Localhost" 

# Get Citrix licensing Info
$licensePool = gwmi -class "Citrix_GT_License_Pool" -Namespace "Root\CitrixLicensing" -comp $StrHost

$LicensePool | ForEach-Object{ If ($_.PLD -eq "MPS_ADV_CCU"){
    $Total = $Total + $_.Count
    $InUse = $InUse + $_.InUseCount
    }
}

$PercentUsed = [Math]::Round($inuse/$total*100,0)
$Free = [Math]::Round($Total-$Inuse)

echo "Total: ",$Total
echo "In Use: ",$InUse
echo "Free: ",$Free
echo "Percent Used: ", $PercentUsed
VN:F [1.9.22_1171]
Rating: 6.0/6 (3 votes cast)

Installing SCOM 2012 Web Console prerequisites with powershell

I need the Web Server (IIS) role with the follow server role services:  According to http://technet.microsoft.com/en-us/library/hh205990.aspx#BKMK_RBF_WebConsole

  • Static Content
  • Default Document
  • Directory Browsing
  • HTTP Errors
  • HTTP Logging
  • Request Monitor
  • Request Filtering
  • Static Content Compression
  • Web Server (IIS) Support
  • IIS 6 Metabase Compatibility
  • ASP.NET
  • Windows Authentication

I could go to Server Manager and add the individual roles and features, but I am running Server 2008 R2 so lets make it super simple with PowerShell.

1. Launch the PowerShell command prompt

2. Run this command

Import-Module ServerManager

3. Press Enter

4. Run this command

Add-WindowsFeature NET-Framework-Core,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Http-Logging,Web-Request-Monitor,Web-Filtering,Web-Stat-Compression,AS-Web-Support,Web-Metabase,Web-Asp-Net,Web-Windows-Auth –restart

5. Press Enter

6. If you already installed .net 4.0 then you will need to run this command from PowerShell to register IIS with .net 4.0

c:\windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -r

7.  Now I need to enable IIS to work with .net 4.0

c:\windows\system32\inetsrv\appcmd set config /section:isapiCgiRestriction /[path=`’C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll`’].allowed:True

VN:F [1.9.22_1171]
Rating: 6.0/6 (2 votes cast)

Change Language on NDR Messages In Exchange 2010

When Exchange Server 2010 have to send out NDR messages it will attempt to detect the language of the message, and reply in that language,
If it cannot detect the language, it will reply in the default language from It’s configuration.

To change the language in the configuration, run these commands in Exchange Management Shell:

NDRs for mails received from external domains:

Set-TransportConfig -ExternalDsnDefaultLanguage en-us

And for NDRs for mails received from internal domains:

Set-TransportConfig -InternalDsnDefaultLanguage en-us

Disable auto detection from external domains:

Set-TransportConfig -ExternalDsnLanguageDetectionEnabled $false

Disable auto detection from internal domains:

Set-TransportConfig -InternalDsnLanguageDetectionEnabled $false

VN:F [1.9.22_1171]
Rating: 0.0/6 (0 votes cast)

Enable all users in an OU for Lync 2010 with Powershell

If you want to enable all users in a OU for lync use this powershell command:

get-csADuser -OU "OU=Office,OU=Head,dc=dcserver,dc=local" | Enable-CsUser -RegistrarPool YOUR-LYNC-POOLSERVER -SipAddressType emailaddress
VN:F [1.9.22_1171]
Rating: 0.0/6 (0 votes cast)

Set calendar-permissions for mailboxes in Exchange Server 2010

I was looking for at way to set default calendar-permissions in exchange 2010, and found out that the only way to do this, is the scripting way.

So i found a script and modified it ( ALOT ) to fit my need

#Load Exchange Server 2010 Management Shell if not loaded.

if (-not (Get-PSSnapin | Where-Object {$_.Name -like "Microsoft.Exchange.Management.PowerShell.E2010"})){
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
}

#Custom variables
$mailboxes = Get-Mailbox
$AccessRights = "Reviewer"

#Loop through all mailboxes
foreach ($mailbox in $mailboxes) {

#Retrieve name of the user`s calendar
$calendar = (($mailbox.SamAccountName)+ ":\" + (Get-MailboxFolderStatistics -Identity $mailbox.SamAccountName -FolderScope Calendar | Select-Object -First 1).Name)

#Check if calendar-permission for user "Default" is set to the default permission of "AvailabilityOnly"
if (((Get-MailboxFolderPermission $calendar  | Where-Object {$_.User -like "Default"}).AccessRights) -like "AvailabilityOnly" ) {

Write-Host "Updating calendar permission for $mailbox..." -ForegroundColor Yellow

#Set calendar-permission for user "Default" to value defined in variable $AccessRights
Set-MailboxFolderPermission -User "Default" -AccessRights $AccessRights -Identity $calendar
}
}

And then a bat file to execute it from “scheduled task”

powershell -command "& 'C:\PATH-TO-FILE\Set-CalendarPermissions.ps1' "

VN:F [1.9.22_1171]
Rating: 5.3/6 (3 votes cast)

Lync 2010 Assign Client Policies By Active Directory Groups

After we got our new Lync 2010 setup done, we was missing one key feature.
We want to assign Client policies by Active Directory groups instead of the need to login to Lync admin and change it.

So we made a simple powershell script to do the work for us

save it as Lync-SetClientPolicy.ps1

Import-Module "C:\Program Files\Common Files\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1"
$ADGroupName = $args[0]
$ClientPolicy = $args[1]

$strFilter = "(&(objectCategory=Group)(SamAccountName=" + $ADGroupName +"))"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher

$objSearcher.SearchRoot = $objDomain

$objSearcher.Filter = $strFilter

$objSearcher.SearchScope = "Subtree"

$colProplist = "member"

foreach ($i in $colPropList)

{[void] $objSearcher.PropertiesToLoad.Add($i)}

$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
{
$objItem = $objResult.Properties;
$group = $objItem.member
}

foreach ($user in $group)

{
$userlync= Get-CsUser -Identity $user
if ($userlync.ClientPolicy -like $ClientPolicy)
{

}
else
{
Grant-CsClientPolicy $user -PolicyName $ClientPolicy
}

}

And then a bat file to execute it from “scheduled task”

powershell -command "& 'C:\script\Lync-SetClientPolicy.ps1' "Lync-ClientPolicy-Sales" "Sales" "
powershell -command "& 'C:\script\Lync-SetClientPolicy.ps1' "Lync-ClientPolicy-Default" "Default" "
VN:F [1.9.22_1171]
Rating: 0.0/6 (0 votes cast)