Tuesday, 2 June 2015

How to Remove the Header of CSV file

#TYPE System.Management.Automation.PSCustomObject

 
To eliminate the above header from CSV file while using Export-CSV command, add -NoTypeInformation

Export-CSV "Location where you want to save the CSV file" -NoTypeInformation

Thursday, 23 April 2015

Sending Lync Events by Email


$servers = "Server1","Server2"
$filepath = "C:\Scripts\"
$date = "{0:dd-MM-yyyy_HH-mm}" -f (get-date)
$file = $filepath + "ErrorLogs_" + $date + ".txt"
New-Item $filepath -type directory -force -Verbose
foreach($server in $servers)
{
$server | Out-File $file -Append
Get-Eventlog -log "Lync Server" -cn $Server -after ((get-date).addDays(-1)) -EntryType Error | Out-File $file -append

}
Send-MailMessage -To "anilkumar.nudurupati@testlab.com","anilkumar.nudurupati@testlab.com" -From "Lync.Monitoring@testlab.com" -Subject "Lync Server Events" -Attachments "$file" -SmtpServer "10.1.1.0"

Wednesday, 22 April 2015

How to check if a remote server is reachable

You can store the servers in $Servers variable

_________________________________________________________________

$Servers = "Server1","Server2","Server3"

Foreach ($Server in $Servers)
{

  $StatusPC = Test-Connection -Cn $Server -BufferSize 16 -Count 1 -ea 0 -quiet

      if ($StatusPC -eq $True)
       {    
       Write-host
       Write-host "$Server is reachable" -foregroundcolor Green -backgroundcolor black
       }

       else
       {
        Write-host
        Write-host "$Server is not reachable" -foregroundcolor Red -backgroundcolor black
       }

}

       Write-host


_________________________________________________________________

Note: If the servers are reachable you will be able to see the output in Green if not then you will see Red 


Alternate One-Liner Script:
get-content servers.txt | % {new-object psobject -property 
@{ComputerName=$_; Reachable=(test-connection -computername $_ -quiet -count 1)} }  
| ft -AutoSize

Wednesday, 4 February 2015

How to check when the certificate gets expired on Lync Server

You can use the Lync Management Shell to check the certificate expiry status

Open Lync Management Shell

Run the below command

Get-CsCertificate | ft Issuer, Use, Subject, NotAfter

or

Get-CsCertificate | Out-GridView

Monday, 2 February 2015

How to connect to Lync Server remotely from Windows PowerShell

Open a Notepad and save the below script and save the file as .PS1

************************************************************************************
# get creds for remote environment
$credential = get-credential "Domain\SamAccountName"
# set session options to bypass the PKI checks - I trust the far side
$sessionoption = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
#create new session
$session = New-PSSession -ConnectionUri https://Server.domain.com/ocspowershell -Credential  $credential -SessionOption $sessionOption

# assuming the above line worked, import the cmdlets needed for Lync
import-pssession $session | FT -wrap

**************************************************************************************

Note: If you are trying to connect to Lync Server 2013 server, then ensure your Windows PowerShell is having 3.0 version


Monday, 26 January 2015

Instant Translation with Lync 2013

I was wondering if my Lync Client can translate my IM messages when i send the messages to other colleagues in their local language. I found the below work around to achieve my goal.

Open a Notepad and copy the below code and save it as Translate.Reg

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\MicrosoftOffice\15.0\Lync\Addins\{2b26edf9-92e0-4d9c-9d7a-f772fcd4f31b}]
"Name"="Lync Conversation Translator"
"Parameters"=""
"ExtensibilityApplicationType"=dword:00000000
"ExtensibilityWindowSize"=dword:00000001
"DefaultContextPackage"=dword:00000000
"InternalURL"="http://go.microsoft.com/fwlink/?LinkID=68810&Lync=y"
"ExternalURL"="http://go.microsoft.com/fwlink/?LinkID=68810&Lync=y"


[HKEY_CURRENT_USER\Software\Microsoft\Office\Lync\Security]

[HKEY_CURRENT_USER\Software\Microsoft\Office\Lync\Security\Trusted Sites]

[HKEY_CURRENT_USER\Software\Microsoft\Office\Lync\Security\Trusted Sites\conversationtranslator.cloudapp.net]
"http"=dword:00000001
"https"=dword:00000001


Right Click on the Translate.Reg and Click Merge and Click OK to update the registry entries

Exit and Restart Lync Client 2013

Once you start Lync 2013 you will find ... in the IM Conversation window, now you need to do the settings of yours and other user language. If you don't do then you will get below error


Once you provide the correct settings, you will be able to modify the language of your or others to which you are sending the IM message




Note: You must have Silverlight installed in your system

Friday, 23 January 2015

Modify the SIP address of an Enabled Lync User

For various reasons you may need to modify the SIP address for eg if you have acquired a new company and you want them to use the existing domain name in their SIP address.

For a Single User, you can run the below command:

Set-CsUser -Identity "Anil Kumar Nudurupati" -SipAddress "anilkumar.nudurupati@newsipdomain.com"


If the same task if you have to do for multiple users, then it will be a tedious task if you perform via Control Panel or by running above powershell command. For this you need to use the below PowerShell Script.

For Bulk Users

$users=Import-Csv .\users.csv
foreach ($user in $users)
    {
        $oldAddress = $user.SipAddress
        $newAddress = $oldAddress -replace "@oldsipdomain.com", "@newsipdomain.com"
        Set-CsUser -Identity $user.Identity -SipAddress $newAddress
    }