Get Live Currency Rate From Yahoo Finance API

Here is a simple PHP Function to get live currency conversion from Yahoo Finance API

In my example i am gettting the value of 100 Dansih Krone in US Dollar

<?php
function yahoofinance_convert($from, $to) {
$url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s='. $from . $to .'=X';
$handle = @fopen($url, 'r');

if ($handle) {
$result = fgets($handle, 4096);
fclose($handle);
}
$return = explode(',',$result);
$to_value = $return[1] * 100;

return $to_value;
}

echo "Value of 100 DKK is " . yahoofinance_convert("DKK", "USD") . "$";

?>
VN:F [1.9.22_1171]
Rating: 5.5/6 (4 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 "&amp; '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 = "(&amp;(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 "&amp; 'C:\script\Lync-SetClientPolicy.ps1' "Lync-ClientPolicy-Sales" "Sales" "
powershell -command "&amp; 'C:\script\Lync-SetClientPolicy.ps1' "Lync-ClientPolicy-Default" "Default" "
VN:F [1.9.22_1171]
Rating: 0.0/6 (0 votes cast)