Check server accounts in Active Directory.

I made a simple powershell to list server accounts in AD, list versions and service pack level. It will also do a simple test-connection to see if it is alive (remember 2008 firewall will block icmp by default.

Import-Module activedirectory
$htmlheader = “<html><head></head><body><table>”
$trtdstart =”<tr><td>”
$trtdstart3 =”<tr bgcolor=#80ff80><td>”
$trtdstart1 =”<tr bgcolor=#40FF00><td>”
$trtdstart2 =”<tr bgcolor=#FF8080><td>”
$tdstart =”<td>”
$tdstartstop=”</td><td>”
$tdend=”</td>”
$trtdend =”</td></tr>”
$htmlfoot= “</table></body></html>”
$counter = 1
$servere = get-adcomputer -filter {(Operatingsystem -like “*server*”)} -properties Name,OperatingSystem,OperatingSystemVersion,OperatingSystemServicePack -ResultSetSize 4000 -SearchScope subtree | Sort-Object -Property Name
$htmlheader | Out-File  -FilePath C:\Powershell\servers.htm
$servere | ForEach-Object -process {
   $gruppe= $null
   $pingtest = Test-Connection -ComputerName $_.Name -WarningAction silentlycontinue -Count 1 -ErrorAction silentlycontinue
   if ($_.OperatingSystemVersion -like “*6.1*”){
        $trtdstart1 | Out-File  -FilePath C:\Powershell\servers.htm -Append
    } elseif ($_.OperatingSystemVersion -like “*6.0*”){
        $trtdstart1 | Out-File  -FilePath C:\Powershell\servers.htm -Append
    } elseif ($_.OperatingSystemVersion -like “*5.2*”){
        $trtdstart3 | Out-File  -FilePath C:\Powershell\servers.htm -Append
    } else
    {
        $trtdstart2 | Out-File  -FilePath C:\Powershell\servers.htm -Append
    }
    $Counter| out-file -FilePath C:\Powershell\servers.htm -Append
    $Counter=$Counter+1
$tdstartstop | Out-File  -FilePath C:\Powershell\servers.htm -Append
    $_.Name| out-file -FilePath C:\Powershell\servers.htm -Append
$tdstartstop | Out-File  -FilePath C:\Powershell\servers.htm -Append
    $_.OperatingSystem| out-file -FilePath C:\Powershell\servers.htm -Append
$tdstartstop | Out-File  -FilePath C:\Powershell\servers.htm -Append
    $_.OperatingSystemVersion| out-file -FilePath C:\Powershell\servers.htm -Append
$tdstartstop | Out-File  -FilePath C:\Powershell\servers.htm -Append
    $_.OperatingSystemServicePack | out-file -FilePath C:\Powershell\servers.htm -Append
    $tdstartstop | Out-File  -FilePath C:\Powershell\servers.htm -Append
    $pingtest.IPV4Address.IPaddresstostring  | Out-File  -FilePath C:\Powershell\servers.htm -Append
    $tdstartstop | Out-File  -FilePath C:\Powershell\servers.htm -Append
    if ($pingtest) { “Echo reply” |Out-File  -FilePath C:\Powershell\servers.htm -Append } else { “No reply” |Out-File  -FilePath C:\Powershell\servers.htm -Append }
    $tdstartstop | Out-File  -FilePath C:\Powershell\servers.htm -Append
     $trtdend | Out-File  -FilePath C:\Powershell\servers.htm -Append
}
$htmlfooter | out-file -FilePath C:\Powershell\servers.htm -Append

 

Error 1603 installing Exchange 2010 RollUp’s

Getting error installing Rollup 5 for Exchange 2010 Sp1. Error 1603. According to msi log file it is ServiceControl.ps1 that is causing the error. Solution was to set execution policy to RemoteSigned and also run the “ServiceControl.ps1 AfterPatch” script from the Exchange 2010 Bin folder . Also remember to start Powershell as administrator.

set-executionpolicy -executionpolicy RemoteSigned

.\servicecontrol.ps1 AfterPatch

After this the install turned out OK.

Test network with filecopy and Powershell

Needed a way to test and time filecopy between servers using powershell. This is what I came up with. This example will use copy testfile.zip to server and time the progress. I used a file of 1.8 Gb.

$servers=”server1″,”server2″,”server3″,”server4″,”server5″,”server6″
foreach($server in $Servers){
if (!(test-path \\$server\share\temp)) {
    new-item -path \\$server\share -name temp -ItemType Directory
}
$start = get-date
copy-item C:\temp\testfile.zip -Destination \\$server\share\temp\testfile.zip
$end = get-date
Remove-Item \\$server\share\temp\testfile.zip
[TimeSpan]$Totaltid = new-timespan $start $end
write-host $($server) – $($Totaltid.seconds)s
}

Install Windows Phone 7 SDK on windows 2008 R2

Aaron Stebner’s WebLog shows us how to install Windows Phone 7 SDK on Windows 2008 R2.

http://blogs.msdn.com/b/astebner/archive/2010/05/02/10005980.aspx

  1. Download the Windows Phone Developer Tools web bootstrapper and save it to your hard drive
  2. Extract the contents of the setup package by running vm_web.exe /x and choosing a path to extract to
  3. Go to the folder you extracted to in step 2 and open the file baseline.dat in notepad
  4. Look for the section named [gencomp7788]

    Note – you have to change this exact section – this is the one that controls the OS version blocking behavior in Windows Phone Developer Tools setup.

  5. Change the value InstallOnLHS from 1 to 0
  6. Change the value InstallOnWin7Server from 1 to 0
  7. Save and close baseline.dat
  8. Run setup.exe /web from the folder you extracted to in step 2

Updated: This also works for WP7.1 sdk Laughing

List activesync device statistics

Some times it is usefull to get a list of when did devices last sync.

get-mailbox | ForEach-Object { Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity;}| Out-File -filepath c:\powershell\activesync.txt

Or if you want to list spesific devices:

get-mailbox | ForEach-Object { Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity;}|where {$_.devicefriendlyname -eq “Touch_DUal”}| Out-File -filepath c:\powershell\activesync.txt

 

Preparing for my next certification.

I have been working with Lync since the early beta versions. Now I think it is time to test my skills and go for TS 70-664 Configuring Lync server. Here in Norway nearly all our customers are medium (->600 employees) so some functions built for large enterprises are rearly used. These are the things that I will have to read extra carefully, and my lab environment  will continue to grow.

 

Atle

List used phone numbers in Lync

This will list all used phone numbers in Lync. Except those used by Exchange UM (Auto Attendant ..)

$LUser=Get-csuser -Filter {LineURI -ne $Null}
$PLUser=Get-CsUser -Filter {PrivateLine -ne $Null}
$LCommonarea=Get-cscommonareaphone -Filter {LineURI -ne $Null}
$LAnaloge=Get-csanalogdevice -Filter {LineURI -ne $Null}
$LAppEndPoint=Get-CSApplicationEndPoint -Filter {LineURI -ne $Null}
$LExchUM=Get-CsExUmContact -Filter {LineURI -ne $Null}
$LDialIN=Get-CsDialInConferencingAccessNumber -Filter {LineURI -ne $Null}
$Workflow=Get-CsRgsWorkflow
$LDevices=$LDialIN+$PLUser+$LUser+$LCommonarea+$LAnaloge+$LAppEndPoint
$LDevices|sort-object -property Lineuri | ft DisplayName,LineUri

 

*.cshtml files return html error 404 in BlogEngine.NET 2.5

I was searching for some help on this error for days. Tried adding different mappings. Then I found this page :

http://www.sven-s.de/post/BlogEngine-HTTP-4043-cshtml-Handler-not-registered-in-Shared-Hosting.aspx

 “

HTTP Error 404.3 – Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

The solution is, to add the following handlers to web.config:

<system.webServer>
  <handlers>
    <add name="cshtml-ISAPI-4.0_32bit" path="*.cshtml" verb="GET,HEAD,POST,DEBUG" 
         modules="IsapiModule" 
scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> <add name="cshtml-ISAPI-4.0_64bit" path="*.cshtml" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule"
scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> <add name="cshtml-Integrated-4.0" path="*.cshtml" verb="GET,HEAD,POST,DEBUG" type="System.Web.HttpForbiddenHandler"
preCondition="integratedMode,runtimeVersionv4.0" /> </handlers> </system.webServer>

Added this settings to the web.config file in the admin folder and “Wham bam thank you…….”. Now it it works.

 

Atle

Move Lync database to new sql server.

This is how I’ve done it. First in lab then in production. This is moving enterprise edition databases. For this to work you need one extra temporary sql server and one Lync server in a temporary Lync pool ,along with the new SQL production server.

1. Export Lync configuration just in case.
export-csconfiguration -file c:\lyncconfig.zip
export-cslisconfiguration -file c:\lynclisconfig.zip
2. Install a new Lync server in a new pool. I.e temppool.corp.local
3. Install a new CMS (configuration management store) on temporary sql server.
install-csdatabase -CentralManagementDatabase -sqlserverfqdn tempsql.corp.local
4. Enable topology.
enable-cstopology
5. Logon to new server in new pool and move CMS Lync server.
move-csmanagementserver
Verify that you are moving it to the new server and select.
Get-csmanagementreplicationstatus
Wait for replication.
6. Uninstall old CMS database.
Uninstall-csdatabase -CentralManagementDatabase -sqlserverfqdn OLDSQLSERVERFQDN.corp.local
7. Backup Lync databases. All of them.
8. In topologybuilder create a new sql server at the enterprise pool properties and publish topology.
9. Run Lync server setup deployment wizard.
10. Turn off all Lync frontend servers.
11. Restore Databases to the newley created databases. Remember to enable Chaining on the RTC and RTCDYN databases. Enable cross database chaining in the sql server properties. (SQL 2008 R2) In SQL-query : alter-database rtc set db_chaining = on alter-database rtcdyn set db_chaining = on
12. Start Lync servers.
13. Mover CMS to new SQLserver. step 1 – 6
14. Delete temppool from topologybilder and publish.

-MS Stuff-