- PowerShell script blocks can contain a begin, process and end script block as described here: http://technet.microsoft.com/en-us/magazine/hh413265.aspx or here: http://mjolinor.wordpress.com/2012/03/11/begin-process-end-not-just-for-functions/
- In order to access Microsoft.NET Static methods, you can use the double colon notation in front of the respective Microsoft.NET Class such as described here: http://technet.microsoft.com/en-us/library/dd347632.aspx
- You can embed C# class within PowerShell scripts as described here: http://blogs.technet.com/b/stefan_gossner/archive/2010/05/07/using-csharp-c-code-in-powershell-scripts.aspx
- You can even assign script blocks to variables as described here: http://ss64.com/ps/syntax-variables.html
- You can write out long strings using Here-Strings as described here: http://technet.microsoft.com/en-us/library/ee692792.aspx and here: http://blogs.msdn.com/b/powershell/archive/2006/07/15/variable-expansion-in-strings-and-herestrings.aspx
- You can send output to the console as well as a variable as described here: http://blogs.technet.com/b/heyscriptingguy/archive/2013/02/23/powertip-easily-send-output-to-both-the-powershell-console-and-a-variable.aspx
- You can get a listing of PowerShell command aliases as described here: http://blogs.technet.com/b/heyscriptingguy/archive/2011/01/15/weekend-scripter-discovering-powershell-cmdlet-parameter-aliases.aspx
- You can define parameters explicitly (instead of using $args variable) as described here: http://technet.microsoft.com/en-us/magazine/jj554301.aspx
- You can validate your script parameters as described here: http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx
- You can use Invoke-Expression or Invoke-Command to command presented as strings as described here: http://richardspowershellblog.wordpress.com/2011/06/14/powershell-basics-invoking-commands/
- You can test out your commands before actually executing them by using the -whatif parameter as described here: http://www.computerperformance.co.uk/powershell/powershell_whatif_confirm.htm. You can also easily add -whatif support to your own PowerShell functions as outlined here: http://blogs.technet.com/b/heyscriptingguy/archive/2012/07/08/weekend-scripter-easily-add-whatif-support-to-your-powershell-functions.aspx
- To work with Key/Value Pair Collections in PowerShell, you can use Hash Tables: http://technet.microsoft.com/en-us/library/ee692803.aspx
Tuesday, March 12, 2013
Little Known PowerShell Tips & Tricks
Friday, March 8, 2013
Removing Roles and Features in Windows Server 2012
Unlike in previous versions of the Server OS, in Windows Server 2012, you do not simply re-run the Roles and Feature Wizard to uncheck the Roles and Features that have already been installed (though the process is only slightly different).
Instead, you must go into the Dashboard for the Local Server and navigate to the Roles and Features section to remove individual roles and features. You can select an individual role or feature for removal and then right click on the selected Role or Feature to remove it. After selecting this menu option, this will once again open the Remove Roles and Features Wizard whereby you can unhceck the roles and features you wish to specifically remove.
Instead, you must go into the Dashboard for the Local Server and navigate to the Roles and Features section to remove individual roles and features. You can select an individual role or feature for removal and then right click on the selected Role or Feature to remove it. After selecting this menu option, this will once again open the Remove Roles and Features Wizard whereby you can unhceck the roles and features you wish to specifically remove.
Thursday, March 7, 2013
Testing an ADFS Installation without SharePoint
If you are planning a deployment of SharePoint with Claims-based authentication using ADFS (Active Directory Federation Services), chances are you will want to set up ADFS on a separate server and verify that it is working properly before you configure it to work with SharePoint.
Normally, you would have to set up a test application such as an ASP.NET Web Application using the Windows Identity Foundation SDK to verify the functionality and integration of ADFS.
Fortunately, there is a little known feature in ADFS once it is installed which allows you to test an installation of ADFS without an application!
This feature is in the form of a page called IdpInitiatedSignOn.aspx which is located in the root of the /adfs/ls directory. Therefore, it can be found at a Url similar to the following https://<adfs fqdn>/adfs/ls/IdpInitiatedSignOn.aspx
You can find this page by browsing the Content View in IIS to locate the name of the page:
If you want to simplify your life further, you can turn on FormsSignIn and make it the default authentication type in the web.config file (located beneath C:\inetpub\adfs\ls). By default, the FormsSignIn.aspx element is not the first element in the web.config file. You can simply cut and paste it as the first line below localAuthenticationTypes as shown in the screenshot below:
Once you have everything configured, you should be able to log into the IdpInitiatedSignOn.aspx page and see a page similar to the following:
If you are able to successfully log into your ADFS instance using your Windows Active Directory credentials, you have correctly setup and configured your ADFS installation and can proceed with integrating ADFS with SharePoint as a Trusted Identity Provider!
Congratulations!!
Normally, you would have to set up a test application such as an ASP.NET Web Application using the Windows Identity Foundation SDK to verify the functionality and integration of ADFS.
Fortunately, there is a little known feature in ADFS once it is installed which allows you to test an installation of ADFS without an application!
This feature is in the form of a page called IdpInitiatedSignOn.aspx which is located in the root of the /adfs/ls directory. Therefore, it can be found at a Url similar to the following https://<adfs fqdn>/adfs/ls/IdpInitiatedSignOn.aspx
You can find this page by browsing the Content View in IIS to locate the name of the page:
If you want to simplify your life further, you can turn on FormsSignIn and make it the default authentication type in the web.config file (located beneath C:\inetpub\adfs\ls). By default, the FormsSignIn.aspx element is not the first element in the web.config file. You can simply cut and paste it as the first line below localAuthenticationTypes as shown in the screenshot below:
Once you have everything configured, you should be able to log into the IdpInitiatedSignOn.aspx page and see a page similar to the following:
If you are able to successfully log into your ADFS instance using your Windows Active Directory credentials, you have correctly setup and configured your ADFS installation and can proceed with integrating ADFS with SharePoint as a Trusted Identity Provider!
Congratulations!!
Internet Explorer 10 now available for Windows 7!!
If you have been waiting for Internet Explorer for Windows 7 to be released, the wait is finally over!!
You can download Internet Explorer 10 from here: http://windows.microsoft.com/en-us/internet-explorer/download-ie
If you are looking for the offline or standalone installations of Internet Explorer 10, you can find them here: http://www.askvg.com/direct-download-link-full-standalone-offline-installers-of-microsoft-internet-explorer-10-ie10/
You can download Internet Explorer 10 from here: http://windows.microsoft.com/en-us/internet-explorer/download-ie
If you are looking for the offline or standalone installations of Internet Explorer 10, you can find them here: http://www.askvg.com/direct-download-link-full-standalone-offline-installers-of-microsoft-internet-explorer-10-ie10/
Wednesday, March 6, 2013
Enabling RadControls in the Sitefinity Toolbox
If you wish to use the RadControls in your Sitefinity Content Pages, you will notice that, by default, the RadControls are not available as widgets to be added to your Sitefinity Content Pages even though Sitefinity ships with the Telerik RadControls (by way of the Telerik.Web.UI DLL/Assembly).
Fortunately, you can enable the RadControls by going into the Toolbox and enabling them so that they display amongst your available widgets:
Fortunately, you can enable the RadControls by going into the Toolbox and enabling them so that they display amongst your available widgets:
- From the Administration menu, select Settings
- Click on Advanced
- Expand the Toolboxes node to view the following: Toolboxes-->Toolboxes-->PageControls-->Sections-->RadControls
- Click on the RadControls menu item
- Select the Enabled check box to enable the RadControls widgets
- You should now be able to add RadControls to you Sitefinity Content Pages!
Tuesday, March 5, 2013
Changing the Color Scheme in Visual Studio 2012
If, like me, you do not like the color themes that ship out-of-the-box with Visual Studio 2012, fortunately, Microsoft has recently released a Visual Studio 2012 Color Theme Editor!!
You can read more about the Visual Studio 2012 Color Theme Editor as well as download it from here:
http://visualstudiogallery.msdn.microsoft.com/366ad100-0003-4c9a-81a8-337d4e7ace05
You can read more about the Visual Studio 2012 Color Theme Editor as well as download it from here:
http://visualstudiogallery.msdn.microsoft.com/366ad100-0003-4c9a-81a8-337d4e7ace05
Friday, March 1, 2013
Intellisense for SharePoint Libraries in PowerShell using PowerGUI and PowerSE
If, like me, you have become addicted to Intellisense and autocompletion from years of Visual Studio, you will be quite a bit disconcerted when you begin working with PowerShell (at least v. 2.0) even in IDEs such as PowerGUI (http://powergui.org/index.jspa) and PowerSE (http://powerwf.com/products/powerse.aspx)
Unlike, Visual Studio which creates the Intellisense and autocompletion of the libraries at design time, most of the Intellisense in PowerShell is actually generated after some code has been executed. Therefore, while you are simply typing and referencing libraries you will not have that wonderful autocompletion and dynamic help for object members like you have in Visual Studio.
Even worse, when you are referencing these libraries, due to the implicit typing of PowerShell, you will not be able to figure out the output of methods and properties when referencing libraries such as SharePoint within PowerShell. This makes it particularly difficult to look up the appropriate reference APIs in the MSDN documentation or determine what is not working correctly when something breaks or throws an exception.
Unfortunately, while you cannot overcome ALL of the limitations of using PowerShell, you can certainly overcome some of the Intellisense problems (even if only partially).
So how do you do that? By using the capabilities of Executing a Selection of code in PowerShell to load up the appropriate library and object references to display Intellisense in either PowerGUI or PowerSE.
In the above screenshot, I highlight a selection of PowerShell code and selected "Execute Selection" in PowerSE. In this manner, I can get PowerSE (or PowerGUI depending on your preferred PowerShell editor of choice) to display the Intellisense for any subsequent SharePoint libraries that I need to use.
So while doing this for every few segments of code that you want to use is INCREDIBLY annoying, at least it is better than nothing and offers you some additional error checking while you are typing and referencing various SharePoint libraries as well as provides the added convenience of being able to leverage PowerShell scripts for executing various tasks in SharePoint without having to compile and deploy .NET assemblies to accomplish those same tasks.
NOTE: It is best to execute selections of code after every few lines that you type so that variables and their respective values remain in memory throughout the composition of your script. Otherwise, you will have to create local variables and assign them values if the referenced variables have not already been loaded into PowerShell memory. If the variables do not exist for a particular segment of PowerShell code, you will get an error/exception message just as you would with .NET (since PowerShell is based on .NET, this makes logical sense)
Unlike, Visual Studio which creates the Intellisense and autocompletion of the libraries at design time, most of the Intellisense in PowerShell is actually generated after some code has been executed. Therefore, while you are simply typing and referencing libraries you will not have that wonderful autocompletion and dynamic help for object members like you have in Visual Studio.
Even worse, when you are referencing these libraries, due to the implicit typing of PowerShell, you will not be able to figure out the output of methods and properties when referencing libraries such as SharePoint within PowerShell. This makes it particularly difficult to look up the appropriate reference APIs in the MSDN documentation or determine what is not working correctly when something breaks or throws an exception.
Unfortunately, while you cannot overcome ALL of the limitations of using PowerShell, you can certainly overcome some of the Intellisense problems (even if only partially).
So how do you do that? By using the capabilities of Executing a Selection of code in PowerShell to load up the appropriate library and object references to display Intellisense in either PowerGUI or PowerSE.
In the above screenshot, I highlight a selection of PowerShell code and selected "Execute Selection" in PowerSE. In this manner, I can get PowerSE (or PowerGUI depending on your preferred PowerShell editor of choice) to display the Intellisense for any subsequent SharePoint libraries that I need to use.
So while doing this for every few segments of code that you want to use is INCREDIBLY annoying, at least it is better than nothing and offers you some additional error checking while you are typing and referencing various SharePoint libraries as well as provides the added convenience of being able to leverage PowerShell scripts for executing various tasks in SharePoint without having to compile and deploy .NET assemblies to accomplish those same tasks.
NOTE: It is best to execute selections of code after every few lines that you type so that variables and their respective values remain in memory throughout the composition of your script. Otherwise, you will have to create local variables and assign them values if the referenced variables have not already been loaded into PowerShell memory. If the variables do not exist for a particular segment of PowerShell code, you will get an error/exception message just as you would with .NET (since PowerShell is based on .NET, this makes logical sense)
Subscribe to:
Posts (Atom)













