Skip to main content

Posts

Elevated or not Elevated - Who is your user?

On my troubleshooting travels, I came across this link precisly addressing the problem I had encountered.  From this though, I quite liked the neat way in which the user account elevation test was completed.  I have modified it slightly to simplify the code, but it still does what it needs to.  Thanks for the post Oisin! $identity = [Security.Principal.WindowsIdentity]::GetCurrent() $principal = new-object Security.Principal.WindowsPrincipal $identity $elevated = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if ($elevated) {"elevated - continue"} else{"Not Elevated"}

Powershell 2 Try / Catch Exceptions

Powershell 2 Try / Catch Exceptions Powershell 2 has a new error handling function in Try / Catch.  The official help file for full details on how to run the command can be found here .  The part I have been looking into is how to define the exceptions which led me to a page on MSDN which lists the inheretance of the class system.exception  - essentially the values allowed in the Catch part of the Try / Catch.  Adding this page to links!

The Ultimate Windows 7 folder

A colleague (thanks Tony) sent me through an email saying ... create this folder on you c drive an take a look inside : AllControlPanels.{ED7BA470-8E54-465E-825C-99712043E01C} The folder contains all the control pannels in one place!  In doing a search on the GUID (the text in the brackets) shows that this has been nicknamed God Mode ... pretty handy I'd say.  To extend this a little further, here is a list of a few more in a format to copy and paste into a command prompt.  It creates and adds all the new folders to a tools folder on the c drive.  Enjoy! Md c:\tools Cd c:\tools md AllControlPanels.{ED7BA470-8E54-465E-825C-99712043E01C} Md LOCATION.{00C6D95F-329C-409a-81D7-C46C66EA7F33} md BIOMETRIC.{0142e4d0-fb7a-11dc-ba4a-000ffe7ab428} md POWER.{025A5937-A6BE-4686-A844-36FE4BEC8B6D} md NOTIFICATION.{05d7b0f4-2121-4eff-bf6b-ed3f69b894d9} md CREDENTIALS.{1206F5F1-0569-412C-8FEC-3204630DFB70} md NETWORKAPPS.{15eae92e-f17a-4431-9f28-805e482daf...

Get group members of large groups via Powershell

Get group members of large groups via Powershell I have always been aware that getting the group membership of large groups has been a challenge and have always managed to avoid addressing the issue.  (Is that what we call the 'Too Hard' pile???) Well, I have had a reason to find this out again, but this time I have Powershell to help me out! Why is this such an issue I hear you ask... this link  expalins why.  In a nut shell, you will only every return a maximum of 1500 members for a group, 1000 if you are querying Windows 2000.  I cannot take any credit for the soulution, I can only pass on a now ancient (in poweshell terms that is) Monad link to how to enumerate all the members of a group from /\/\o\/\/ .  As you will see, this link refers to Monad, the pre-release name for powershell.  Please follow the link above or more from /\/\o\/\/ can be found at thepowershellguy.com meanwhile, I have added my own comments to his sc...

Computer Password Changes in AD

In trying to resolve an issue with regards to computers loosing thier trust relationship with the domain, I found this increadibly good explaination  of how passwords are used and changed in AD.  It goes a long way to explain where is the password change is initiated (the computer, not a DC), what is required to be in place before the change can happen and how it works around an issues it may face. Thanks Manish Singh (from the Directory Services team) for such a detailed post. Added to links too!

Manage Shadow Group Membership - Powershell Function

Manage Shadow Group Membership - PowerShell Function I looked at a quick script to update a shadow group here , and then thought, this would make a good function. I have used my function template (refer to that post if you want to know more about how to format a function), to build up a reusable script to update group membership based on user and computer object location in AD. A traditional shadow group is all members of an OU. In my mind, there are a few assumptions to this statement. Being that you have taken the time to create an OU, put objects in it, and created a group to mirror those objects, you probably have only 1 type of object (i.e. user) and they are all similar in some respect (i.e. same office location). This function takes that in mind and only updates groups with users or computers - not other groups etc. Moving away from the traditional meaning of shadow group, I have added (for my own benefit as I required the functionality) a parameter to change the searchsco...

Powershell v2 Function Template

Powershell v2 Function Template Powershell v2 has updated what you can do with creating functions over Powershell V1. The whole function experience has been updated to a cmdlet like feel with error handling, parameter validation, help creation and of course, tab completion! The following is a bare bones template that I've commented inline for easy reading! function new-template { <# .SYNOPSIS    Brief description of what the function does .DESCRIPTION    A better description .NOTES    Function Name : new-template    Author : Adam Stone    Requires : PowerShell V2 .LINK    http://adadmin.blogspot.com/ .EXAMPLE    Simple usage    PS C:\> new-template -args values .EXAMPLE    Simple usage    PS C:\> new-template -args values values etc .PARAMETER first    A description of the first parameter .PARAMETER targetdomain    A description of the ...