Thursday 19 March 2015

Powershell truncates text

I'm guessing many PowerShell users have had this problem and found several ways to work around it. Truncating of text.

When quickly getting an overview over a PowerShell object nothing is wrong with truncating properties that contains large amounts of text, but sometimes you actually are looking for that specific property. Those times it is annoying when you get this:

$object | select Policies

{NT AUTHORITY\LOCAL SERVICE, SomeAccount Account1, SomeAccount Account2, Accountname...}

This "script window" shows me trying to fetch one property out of a already stored object. The text within the property I am looking for is not visible. Its behind those three dots...

The solution is changing the $FormatEnumerationLimit variable of PowerShell.

As standard is is set to 4. As you also see from the "script window" is that we have gotten 4 items from the Policies property. But there is for certain more than 4 items here.

Do something as simple as set $FormatEnumerationLimit to 20 or possibly -1 to get more or unlimited items from the property.
$FormatEnumerationLimit = -1
$object | select Policies

{NT AUTHORITY\LOCAL SERVICE, SomeAccount Account1, SomeAccount Account2, Accountname, MissingAccountName1, 0#.w|DomainName\MissingAccountName2}


Check these blogposts for more info on the subject(1. simple explanation 2. more elaborate explanation):
http://exchangeserverpro.com/how-to-prevent-truncation-of-long-output-in-exchange-management-shell/

http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/20/change-a-powershell-preference-variable-to-reveal-hidden-data.aspx

Thursday 18 July 2013

Find if AD user or Group exists by using PowerShell

Quickpost

I just needed a fast and quick way to find out if a security group exists in Active Directory via PowerShell for some SharePointregarding business. I actually had to spend a little time searching for this, the simplest of solutions.

PowerShell prompt:

[ADSI]::Exists('WinNT://./usernameorgroup') <- Local users or groups
or
[ADSI]::Exists('WinNT://domainname/usernameorgroup') <- Domain users or groups

This will return true or false.

For my purposes this was exactly what I needed. What limitations this have in regards to security I don't know. But the user i ran this commands with is not a domain admin or has any elevated rights above admin on the said server.

Monday 1 July 2013

SharePoint Color Palette Tool - SharePoint 2013

I might update this blog post later, but for now this is short and sweet.


I just discovered a great tool for quickly editing colors and generating *.spcolor files.
It is a small(1,1mb) Visual Studio-based program for editing color palettes for SharePoint 2013.
The program has a GUI with a site preview and generates an xml style file as one of the ingredients for SharePoint 2013 themes or looks as I believe they call it.

SharePoint Color Palette Tool is avaliable from Microsoft via technet.
http://www.microsoft.com/en-us/download/confirmation.aspx?id=38182

I used this great "guide" for editing my own themes, placing the files in the correct folders directly in the hive OR in the site via SharePoint Designer 2013:

http://bniaulin.wordpress.com/2012/12/16/step-by-step-create-a-sharepoint-2013-composed-look/

Change URL on lists and libraries in SharePoint 2013

I have been told that this is impossible several times. Still I had a requirement to do this, and in SharePoint online its easy. I thought to myself that it should be as easy in the on-premise version so I decided to google it.

After reading through a couple of blogs I still somewhat in the dark. I found one that said it was as easy as to open SharePoint designer 2013 and rename the list(just as in 2010 they said). This however did not work.
I opened the list, changed the name, but the URL was still the same.

But after some searching I found the solution in the comment field of this blog post http://www.idubbs.com/blog/2012/sharepoint-2013-list-library-app-naming/.










SharePoint designer is the way to go. This is how to do it:
  • Go to All files
  • Find the list in the Lists folder or library in the root of All files
  • Rename it 
  • That's it
For those who don't have access to SharePoint Designer:

If you don't have option to open the site in SharePoint Designer then you must save the list as site template and create a new list with that template. But, make sure dependencies like lookup columns, workflows, event receivers etc.

I would say that I would not mind if the SharePoint team made this possible directly from the browser in on-premise SharePoint too, but I guess they have their reasons?

Friday 12 April 2013

Is "Sign in as different user" still in SharePoint 2013?


SharePoint 2010 "Sign in as Different User"
SharePoint 2010: Here it is 

SharePoint 2013 Where is "Sign in as Different User"?
SharePoint 2013: ....












The SharePoint team has, surely for some good reason decided that "Sign in as different user" should not be available to reach easily for users in SharePoint 2013. I've only been involved in SharePoint 2013 in a test and lab environment so far, but I'm already really annoyed by this.

Actually I've heard reasons for removing this possibility. One of the main reasons is that there has been reported many authentication problems with Microsoft Office Suite, or other external programs after logging in as a new user. Common problems were not being able to open files that you should have access to, saving  files as the wrong user etc. There could also be problems with some page content being what the windows authenticated, or old user logged in, being shown.

But for me as a IT Pro this is a missed feature. When configuring and testing SharePoint 2013 (or any other release for that matter), I need to be able to change between accounts often. I don't want to close down my browser for each user change, sit in several browsers or different virtual machines. I need this option and I'm prepared to face the consequences! (work around the problems)

Luckily the link is not completely removed in 2013, it's only hidden

These are the options I've found so far:


Alternative 1 - Simple solution - Simple modification of link

If you're out after a quick fix this is the way to go. It requires you to either have this link avaliable for copy/paste, or that you are better to remember stuff than me.

This is the link required: 
/_layouts/closeConnection.aspx?loginasanotheruser=true.
Paste it after your site, or site collection url and provoke a user change.

This is what I've preferred to do so far.

Alternative 2 - For test or dev environments - Modify an ASP.NET User Control File 15\TEMPLATE\CONTROLTEMPLATES\Welcome.ascx:

Within the 15 hive there's a ASP.NET User Control file which can be modified to get the missed link back right where it used to be. This would be a nice edition to test or development environments for seamless switching between users.

Alternative 3 - simple solution 2.0 - Runas different user

Alternative 3 is a Windows-interface workaround for the problem.

I've taken the liberty to write down recipes for new editions:


From Windows 7/Windows Server 2008.

Startmenu:

•Input the name of your browser
•CTRL + SHIFT right click
•Run as different user





















From Windows 8/Windows Server 2012.

From the "tile interface"/aka the new and less intuitive start menu.

  • Choose or search and find your browser of choice, 
  • Right click it 
  • "Run as different user" (you find it at the bottom of your screen)