http://taplynx.com/blog/news-announcements/create-ipad-apps-with-taplynx
I will be posting something here REAL soon. Turned a script that was going to take 90 hours into 3 hours!!
The below links were used to create this script. Thanks
http://blogs.msdn.com/powershell/archive/2009/01/10/capture-console-screen.aspx
http://www.sharepointdevwiki.com/display/public/Updating+User+Profiles+in+SharePoint+SSP+using+PowerShell
http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,a332015d-c5dc-4433-a0f3-247fd37b0b04.aspx
Download the file here
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | [void][reflection.assembly]::Loadwithpartialname("Microsoft.SharePoint") | out-null [void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server.Search") | out-null [void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server") | out-null ################################################################################################################# # Get-ConsoleAsText.ps1 # Thanks to http://blogs.msdn.com/powershell/archive/2009/01/10/capture-console-screen.aspx for Get-ConsoleAsText.ps1 # The script captures console screen buffer up to the current cursor position and returns it in plain text format. # # Returns: ASCII-encoded string. # # Example: # # $textFileName = "$env:temp\ConsoleBuffer.txt" # .\Get-ConsoleAsText | out-file $textFileName -encoding ascii # $null = [System.Diagnostics.Process]::Start("$textFileName") ################################################################################################################# function Get-ConsoleAsText{ # Check the host name and exit if the host is not the Windows PowerShell console host. if ($host.Name -ne 'ConsoleHost') { write-host -ForegroundColor Red "This script runs only in the console host. You cannot run this script in $($host.Name)." exit -1 } # Initialize string builder. $textBuilder = new-object system.text.stringbuilder # Grab the console screen buffer contents using the Host console API. $bufferWidth = $host.ui.rawui.BufferSize.Width $bufferHeight = $host.ui.rawui.CursorPosition.Y $rec = new-object System.Management.Automation.Host.Rectangle 0,0,($bufferWidth - 1),$bufferHeight $buffer = $host.ui.rawui.GetBufferContents($rec) # Iterate through the lines in the console buffer. for($i = 0; $i -lt $bufferHeight; $i++) { for($j = 0; $j -lt $bufferWidth; $j++) { $cell = $buffer[$i,$j] $null = $textBuilder.Append($cell.Character) } $null = $textBuilder.Append("`r`n") } return $textBuilder.ToString() } ################################################################ # Pause Script function Pause ($Message="Script Complete. Press any key to continue...") { Write-Host -NoNewLine $Message $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Write-Host "" } ################################################################ function Get-UserProfileConfigManager([string]$siteUrl) { # Need to get a PortalContext object # as we do not have a HttpContext we need to source one the hard way $site=new-object Microsoft.SharePoint.SPSite($siteUrl) $servercontext=[Microsoft.Office.Server.ServerContext]::GetContext($site) $site.Dispose() # clean up ################################################################ # Return the UserProfileConfigManager new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigmanager($servercontext) } function Get-SPProfileManager([string]$siteUrl) { # Need to get a PortalContext object # as we do not have a HttpContext we need to source one the hard way $site=new-object Microsoft.SharePoint.SPSite($siteUrl) $servercontext=[Microsoft.Office.Server.ServerContext]::GetContext($site) $site.Dispose() # clean up ################################################################ # Return the UserProfileManager new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($servercontext) } function Get-SPUserProfile([string]$siteUrl, [string] $u) { $upm= Get-SPProfileManager([string]$siteUrl) if ($upm.UserExists($u) -eq $false) { $upm.CreateUserProfile($u) $upm.GetUserProfile($u) } ################################################################ # Create function function Update-UserProfileProperty() { PARAM ( [string] $siteUrl = $( throw "You must provide a Site Collection Url e.g. 'http://moss/'"), [string] $userName = $( throw "You must provide a User Name e.g. 'DOMAIN\USERNAME'"), [string] $propName = $( throw "You must provide a User Profile Property Name e.g. 'WorkPhone'"), [string] $propValue = $( throw "You must provide a User Profile Property Value e.g. '0400 767 022'") ) END { if ($propValue -eq "NULL" -or $propValue -eq "" -or $propValue -eq "None") { Write-Host "Property '$propName' is not set ('$propValue')" } else { $cm = get-userprofileconfigmanager $siteUrl $spm = Get-SPProfileManager $siteUrl if ($spm.UserExists($userName)) { $userProfile = $spm.GetUserProfile($userName); $tempProp = $spm.Properties.GetPropertyByName($propName); if ($tempProp -eq $null) { throw "User Profile Property '$propName' does not exist!"; } else { $userProfile[$propName].Value = $propValue; $userProfile.Commit(); } write-host -foregroundcolor green "'$propName' User Profile Property updated to '$propValue' for '$userName'" Write-Output "'$propName' User Profile Property updated to '$propValue' for '$userName'" } else { Write-Host -ForegroundColor red "User '$userName' does not exist in User Profiles!" Write-output "User '$userName' does not exist in User Profiles!"; } } } } ################################################################ function MySiteProUpdate{ $username = "IB\Admin", "IB\Guest", "IB\PowerShell" # Set MySite URL $siteUrl = "http://mysites:3000" # Notifies Write-Host "Working... Please Wait" Write-Output " " foreach($u in $username){ # Executes command for all users in this script Write-Output "Executing this command : Update-UserProfileProperty $siteUrl $u ActiveEmployee true" Update-UserProfileProperty $siteUrl "$u" "ActiveEmployee" "true" } # Dump Console $textFileName = "C:\IBLogs\ConsoleDump.txt" Get-ConsoleAsText | out-file $textFileName -encoding ascii #$null = [System.Diagnostics.Process]::Start("$textFileName") pause } ################################################################ MySiteProUpdate | out-File C:\IBLogs\Progress.txt |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | ############################################################################################################### ##Deactivate a Feature on all Sites for a web application ### ## http://Blog.IsaacBlum.com ## ############################################################################################################### ############################################################################################################### #Create function deactivatefeature function deactivatefeature{ ## Reference to SharePoint DLL [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") ## Location of sharepoint STSADM utility program, You may need to change this $stsadm = "$env:programfiles\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\STSADM.EXE" #Ask for WebApp Root url to enumerate $url = Read-Host "Please enter root url of WebApplication" #Enumerate available features in SharePoint Farm write-host -foregroundcolor green " Below are the available features in SharePoint Farm" &stsadm -o scanforfeatures #Ask for Feature Name Write-Host "Please enter feature name that will be deactivated at all Sites and Sub-Sites of the specified application" $feature = Read-Host "do not add the \feature.xml. ex: NewsGator.SocialSites.SiteSkin" #Returning info for use in remainder of script $webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($url) #List Sites Affected write-host -foregroundcolor green " The feature will be deactivated on the following Sites:" foreach ($site in $webapp.Sites) { # write-host $webapp.Name foreach ($web in $site.AllWebs) { write-host $web.URL }} ##Actvate Feature on all Sites foreach ($site in $webapp.Sites) { foreach ($web in $site.AllWebs) { $sResult = &stsadm -o deactivatefeature -name $feature -url $web.URL -force if(($sResult -like "*Operation completed successfully*")){ write-host -foregroundcolor green "Feature Deactivated : "$web.URL} else { Write-Host -ForegroundColor "red" -BackgroundColor "white" "Deactivate of feature '$feature' for" $web.URL "Failed! `n $sResult" } } } } ############################################################################################################### ############################################################################################################### ############################################################################################################### |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | ########################################################## ##Actvate a Feature on all Sites for a web application ### ## http://Blog.IsaacBlum.com ## ########################################################## ########################################################## #Create function activatefeature function activatefeature{ ## Reference to SharePoint DLL [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") ## Location of sharepoint STSADM utility program, You may need to change this $stsadm = "$env:programfiles\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\STSADM.EXE" #Ask for WebApp Root url to enumerate $url = Read-Host "Please enter root url of WebApplication" #Enumerate available features in SharePoint Farm write-host -foregroundcolor green " Below are the available features in SharePoint Farm" &stsadm -o scanforfeatures #Ask for Feature Name Write-Host "Please enter feature name that will be activated at all Sites and Sub-Sites of the specified application" $feature = Read-Host "do not add the \feature.xml. ex: %featurename%" #Returning info for use in remainder of script $webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($url) #List Sites Affected write-host -foregroundcolor green " The feature will be actvated on the following Sites:" foreach ($site in $webapp.Sites) { # write-host $webapp.Name foreach ($web in $site.AllWebs) { write-host $web.URL }} ##Actvate Feature on all Sites foreach ($site in $webapp.Sites) { foreach ($web in $site.AllWebs) { $sResult = &stsadm -o activatefeature -name $feature -url $web.URL -force if(($sResult -like "*Operation completed successfully*")){ write-host -foregroundcolor green "Feature Actvated : "$web.URL} else { Write-Host -ForegroundColor "red" -BackgroundColor "white" "Activate of feature '$feature' for" $web.URL "Failed! `n $sResult" } } } } ######## ######## ######## |
Add the below code to any PowerShell script to call a pause.
This code is made possible by http://blogs.msdn.com/powershell/archive/2007/02/25/pause.aspx
1 2 3 4 5 6 | function Pause ($Message="Press any key to continue...") { Write-Host -NoNewLine $Message $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Write-Host "" } |
Thanks to http://blogs.msdn.com/sharepoint/archive/2007/03/02/be-wary-when-removing-or-replacing-the-my-site-link.aspx and http://suguk.org/forums/thread/6898.aspx.
I needed a way of adding a link back to the portal site, when in my MySite. I went to “Personalization site links”. Added a link but every time it would add the http://%yoururl%/default.aspx?MySiteView=1 . Made me crazy. Anyway thanks to the folks that bloged about it first.








