Tech
Dave's Tech Blog
Dave's Tech Blog
Nov 30th
Enabling Remote WMI and DCOM for PowerShell Use
Many cmdlets have a built-in -ComputerName parameter that will allow for remote access without using the new PowerShell remoting. For this to work, your firewall will need to be adjusted on the target machine:
netsh firewall set service type = remoteadmin mode = enable
In addition, some cmdlets (like Get-Service) will need the Remote Registry service to be running on the target side:
Start-Service RemoteRegistry
Set-Service RemoteRegistry -StartupType Automatic
Oct 2nd
Since we wrote this script it has helped us get info about specific jobs really quickly. You can download this script here: SharePoint 2010 – Get Job History or copy it here:
cls
$test = Get-SPWebApplication "http://intranet/"
$myStartTime = "9/29/2011 12:30:00 AM"
$myStopTime = "9/29/2011 3:30:00 AM"
#GET ALL BETWEEN THAT TIME PERIOD
Write-Host "Fetching all jobs to JobHistoryOutput.csv for $myStartTime - $myStopTime..." -ForeGroundColor Red
$test.JobHistoryEntries | Where-Object {($_.StartTime -gt $myStartTime) -and ($_.StartTime -lt $myStopTime)} | Export-Csv JobHistoryOutput.csv –NoType
Write-Host "Done! Check JobHistoryOutput.csv for info." -ForeGroundColor Green
#GET ALL THAT FAILED BETWEEN THAT TIME PERIOD
Write-Host "Fetching all errors to JobHistoryOutputErrors.csv for $myStartTime - $myStopTime..." -ForeGroundColor Red
$test.JobHistoryEntries | Where-Object {($_.StartTime -gt $myStartTime) -and ($_.StartTime -lt $myStopTime) -and ($_.Status -ne 'Succeeded')} | Export-Csv JobHistoryOutputErrors.csv –NoType
Write-Host "Done! Check JobHistoryOutputErrors.csv for info." -ForeGroundColor Green
5. View output from the script:
6. You’ll get two files. C:\JobHistoryOutput.csv is all jobs. C:\JobHistoryOutputErrors.csv is jobs that didn’t get a “Succeeded” status. Sort and filter in excel for the results you want: JobDefinitionId, JobDefinitionTitle, WebApplicationId, WebApplicationName, ServiceId, ServerId, ServerName, Status, StartTime, EndTime, DatabaseName, ErrorMessage
Sep 26th
$Domain = ‘LDAP://DC=yourdomain;DC=com’
$Root = New-Object DirectoryServices.DirectoryEntry $Domain
$select = New-Object DirectoryServices.DirectorySearcher
$select.SearchRoot = $root
$adobj= $select.findall() |? {$_.properties.objectcategory -match “CN=Person”}
$adobj.count
For the $Domain variable change the “yourdomain” string to the name of your domain.
Jul 28th
Wow what a huge DEAL!
Our SharePoint 2010 install (2 web Win2K8, 1 app Win2K8, and SQL server 2005) is being backed up via SQL backups and TSM system backups today. This is not recommended by Microsoft to be “the option” because SharePoint can’t be put back together from these backups. It would be missing the IIS deployment and configuration, the SharePoint application server installation, and more.
We explored using the Native Microsoft SharePoint 2010 backup tools but:
So we started to evaluate AvePoint’s DocAve for backing up and administering SharePoint but ran into some road blocks:
So now we have to upgrade our current production SQL environment to MS 2008 Enterprise, then buy DocAve, and then we can finally back it up. Oh and build a SharePoint test environment on some virtual machines too. WHAT A HEADACHE!
Jan 6th
The “Application Templates” (the .wsp files) can be directly deployed to SP2010 in the same manner in which you did it in MOSS2007 (“addsolution” then “deploysolution”).
The “Site Templates” (the .stp files) are no longer supported and must be migrated in the form of an actual site. The process for this would be to first create a site based on each of the templates you’ll want to use (in MOSS2007, or should be able to just bring up a quick deployment of WSS 3.0 and migrate it into SP2010 – havent tried though), migrate the site to SP2010, then save the site as a template to add it to the template store within SP2010 (from then on you’ll be able to create more sites from the same template).
For the “Application Templates” download the complete “All Templates” package (http://www.microsoft.com/downloads/en/details.aspx?familyId=5807B5EF-57A1-47CB-8666-78C1363F127D&hash=U7zPFGJoFxrcdUfx8q5LyWM9C7QgTt9Lz2N1LBkKSJCSHWDA1xGmWvG08XqPxn1%2bH4KlBTCVkFmKjyTTaVP94g%3d%3d), then run a batch file to deploy them all.
The batch file I used is as follows:
Code:
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "AbsenceVacationSchedule.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\ApplicationTemplateCore.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "ApplicationTemplateCore" -allowgacdeployment -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\BudgetingTrackingMultipleProjects.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "BudgetingTrackingMultipleProjects.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\BugDatabase.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "BugDatabase.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\CallCenter.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "CallCenter.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\ChangeRequest.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "ChangeRequest.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\ComplianceProcessSupport.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "ComplianceProcessSupport.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\ContactsManagement.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "ContactsManagement.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\DocumentLibraryReview.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "DocumentLibraryReview.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\EventPlanning.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "EventPlanning.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\ExpenseReimbursementApproval.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "ExpenseReimbursementApproval.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\HelpDesk.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "HelpDesk.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\InventoryTracking.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "InventoryTracking.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\ITTeamWorkspace.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "ITTeamWorkspace.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\JobRequisition.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "JobRequisition.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\KnowledgeBase.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "KnowledgeBase.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\LendingLibrary.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "LendingLibrary.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\PhysicalAssetTracking.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "PhysicalAssetTracking.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\ProjectTrackingWorkspace.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "ProjectTrackingWorkspace.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\RoomEquipmentReservations.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "RoomEquipmentReservations.wsp" -allowgacdeployment -immediate -force
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\unpacked\SalesLeadPipeline.wsp"
call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name "SalesLeadPipeline.wsp" -allowgacdeployment -immediate -force
Copy the above into a “DeployTemplates.bat” file, and place all the “.wsp” templates into a folder called “C:\unpacked”.
The above is written for a Sharepoing 2010 deployment, so to make it work for MOSS2007, simply change the reference from the “14″ to “12″, then it will work.
You should then be able to create new sites from each of these templates.
Oct 29th
Here’s one way to fake a schedule using jobs with the Start-Sleep cmdlet. Let’s say I want to start a job at 19:43:00. You could probably pass dates as well, though. Just place your script name/commands instead of the “Executed!” string.
PS U:\bin> Start-Job -Name USCase98765 -ScriptBlock {Start-Sleep -Seconds ([int]((New-TimeSpan -Start (Get-Date) -End (Get-Date -Hour 19 -Minute 43 -Second 0)).TotalSeconds)); `
(Get-Date);"Executed!"}
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
3 USCase98765 Running True localhost Start-Sleep -Seconds (...
PS U:\bin> Receive-Job -Name USCase98765
Thursday, October 28, 2010 7:43:00 PM
Executed!
Sep 28th
Finally… a OS power efficiency report for Windows! This can help laptop users determine if a driver is bad or not installed, or if the battery is charging completely.
1. To run click on the start button and type “CMD” in the search bar.
2. Type in the command “powercfg -energy” and press enter.

This process will give you a general report shown is the command prompt and also build a nice html report. In my case it put the html file on the C: drive at C:\energy-report.html.
3. Navigate to the report using Windows Explorer and open the html file with your browser (Internet Explorer, Chrome, Firefox, etc.)
4. The report will show you programs that are consuming CPU time AKA power.
For laptop users testing the battery charge:
Near the bottom of the report is information about CPU utilization, processes, and this little gem (screen shot above) This report can help troubleshoot battery usage and charge capacity. This gives admin’s a great way to decide when a battery should be replaced. If the last full charge is consistently dropping from the design capacity it may be time to replace the battery.
With this report Admins can tweak power profiles to realize the maximum benefits of new power efficient computer systems.

Some more info about energy costs:
A kilowatt-hour means using 1000 watts of electricity for 1 hour. Ten 100-watt light bulbs lit for one hour would equal 1 kilowatt hour, or one 100 watt bulb lit for ten hours would equal 1 kilowatt-hour, costing 10 cents. So if one 100 watt bulb costs 10 cents to run for 10 hours and there are 8760 hours in a year, and you push a few buttons on a calculator (876 x .10), you’ll find that the actual cost is $87.60!
My power is now 11 cents per kilowatt-hour, so the cost is now 876 x .11, = $96.36 per year.
If you plan on leaving that 100 watt bulb on a lot, it is worthwile to buy the compact fluorescent version, that uses about 20 watts for the same brightness. (20 watts for 1 year at 11 cents per kilowatt-hour = $19.27 , or about 20 cents on the dollar)
An electric clothes dryer or water heater can use four to six thousand watts. Fortunately, they only operate for short periods of time. (4000 watts for 1 hour at 10 cents would be 40 cents.)
Cost = rate x energy, which contains these units:
$ = $/kWh x kWh
The average computer tower consumes 400 watts. If you have your computer on for 4 hours a day then you used .4 kilowatt-hours which is about $0.44… That can really add up. About $160.60 per computer per year if you use it for 4 hours a day.
Some large television sets can use several hundred watts of power. So if you’re a couch potato, add it up
Jul 29th
VBS has a great function - replace. Next VBS script lets you replace string in a text file. Replace works with text compare (case insensitive). Use:
[cscript|wscript] replace.vbs Find Replacewith File
Find … Required. Substring being searched for.
Replacewith … Required. Replacement substring.
File … Source and destination file for the replacement
Dim FileName, Find, ReplaceWith, FileContents, dFileContents Find = WScript.Arguments(0) ReplaceWith = WScript.Arguments(1) FileName = WScript.Arguments(2) 'Read source text file FileContents = GetFile(FileName) 'replace all string In the source file dFileContents = replace(FileContents, Find, ReplaceWith, 1, -1, 1) 'Compare source And result if dFileContents <> FileContents Then 'write result If different WriteFile FileName, dFileContents Wscript.Echo "Replace done." If Len(ReplaceWith) <> Len(Find) Then 'Can we count n of replacements? Wscript.Echo _ ( (Len(dFileContents) - Len(FileContents)) / (Len(ReplaceWith)-Len(Find)) ) & _ " replacements." End If Else Wscript.Echo "Searched string Not In the source file" End If 'Read text file function GetFile(FileName) If FileName<>"" Then Dim FS, FileStream Set FS = CreateObject("Scripting.FileSystemObject") on error resume Next Set FileStream = FS.OpenTextFile(FileName) GetFile = FileStream.ReadAll End If End Function 'Write string As a text file. function WriteFile(FileName, Contents) Dim OutStream, FS on error resume Next Set FS = CreateObject("Scripting.FileSystemObject") Set OutStream = FS.OpenTextFile(FileName, 2, True) OutStream.Write Contents End Function