Showing posts from March, 2017

CPolydorou.ActiveDirectory Powershell Module

I:ve recently published another of my Poweshell modules to the Powershell Gallery. This time it's the CPolydorou.ActiveDirectory module. This module contains functions that can help with Active Directory tasks. Let's go through the functions and see where they can help. Test-ActiveDirectoryGroupMembership This function will test if an object is member of a group. It also includes a recursive switch. Test-ActiveDirectoryIsDomainAdmin Test if a user is member of the domain admins group. Get-ActiveDirectoryUserGroupMembershipHistory Check when a user was added to a group by examining the Active Directory replication metadata. More functions are going to be added to this module in the near future so make sure you have the latest version installed!

Changing the Exchange Management Shell window title

Although there are advantages in working with Powershell ISE, there may be times when Powershell is a better approach. Take Exchange for example. You may use the exchange commands by connecting to Exchange and using implicit remoting or use the remoteexchange script. For those of us that are using the Exchange Management Shell, I believe that it would be helpful to be able to update the title of the window in order to reflect the use of that particular prompt. Yesterday I put together a function that allows us to set the title of the window. This function is part of my CPolydorou.Exchange module but since that module has not yet been uploaded to the Powershell Gallery, here's the code: Function Rename-ExchangeShell { <# .SYNOPSIS Set the title on the Exchange Shell window. .DESCRIPTION Set the title on the Exchange Shell window. .PARAMETER Title The new title. .EXAMPLE Rename-ExchangeShell -Title "Mailbox Query"

CPolydorou.PSISE Powershell Module

I mostly use Powershell ISE when working with powershell since it provides a more easier way to develop scripts and long commands. I've developed a powershell module that contains some functions that help with ISE. The module is called CPolydorou.PSISE and it's available in Powershell Gallery. Lets go through the functions in the module and their usage. New-PSISETab Create a new Powershell tab in the current ISE window. Rename-PSISETab Rename a Powershell tab Open-PSISEFile Open a file in the current ISE tab. I hope you'll enjoy the module!

Event Log Custom Sources

There are many times where we have to write events on the event log in order to log what a script or program is doing, like an automation scrip for example. We want to be able to find out if a script run or not and where the problem was, if any. I usually create a separate event source on the application log for that purpose, in order to be able to filter the events and not get lost in the application log. Before adding the logging functionality to your script. lets see a couple of commands that are going to be very helpful. First. lets see how we can create a new source. New-EventLog -LogName Application -Source "MyScript" This command will create the source named "MyScript" in the application log. Another command that may come in handy is: [System.Diagnostics.EventLog] :: SourceExists( "MyScript" ) This command will return true if there is a source named "MyScript" on the application log. I've been using this command w

Invoke-Command Array in ArgumentList

When dealing with multiple servers, you may often have to run a powershell command or script on many or all of them. This is where "Invoke-Command" comes into play. The Invoke-Command will execute a powershell command on a remote system and return the results to our powershell console. Let's take a look at a simple example. We are going to test whether or not a folder exists on multiple servers: $servers = @ ( "dc1" , "dc3" ) $servers | %{ Invoke-Command -ComputerName $_ ` -ScriptBlock { Write-Output "C:\Temp" } } The Write-Output cmdlet is executed on the dc1 and dc3 servers. But what if we have to pass parameters to the scriptblock? We will use the -ArgumentList parameter of the Invoke-Command as follows: $servers = @ ( "dc1" , "dc3" ) $path = "C:\Temp" $servers | %{ Invoke-

CPolydorou.Link Powershell Module

A few days ago I uploaded another module to the Powershell Gallery, the CPolydorou.Link module. This module contains function to create and remove NTFS links. Let's go over the functions and their purpose! New-HardLink - Remove-HardLink These functions create and remove NTFS hard links. New-SymbolicLink - Remove-SymbolicLink Those two functions create and remove symbolic NTFS links New-JunctionLink - Remove-JunctionLink These two functions create and remove NTFS junction links. I hope you'll enjoy this module!

CPolydorou.ShadowCopy Powershell Module

Yet another of my Powershell modules has been uploaded to the Powershell Gallery. This time it's the CPolydorou.ShadowCopy module that allows us to create, remove, mount and unmount volume shadow copies. Please note that all the functions of the module have to be run with elevated rights. More information about the module and instructions on how to install it can be found here.

CPolydorou.SystemPath and CPolydorou.PowershellModulePath Powershell Modules

Hello everyone, Two more of my powershell modules were published on the Gallery on the last few days, CPolydorou.SystemPath and CPolydorou.PowershellModulePath. The first module contains functions related to the system path - that is the path that the system searches for executables - that help adding a folder, removing a folder and listing the folders in the system path variable. The second module, helps updating the paths that Powershell searches in order to find modules. Adding a folder on that path can be very helpful when developing a Powershell module. More information about the module and installation instructions can be found here and here .

CPolydorou.HostsFile Powershell Module

Hello everyone, I just published a Powershell module I've developed that helps updating the hosts file. Adding an entry in the hosts file can help you troubleshoot a certificate, a service that is not included in the DNS systems or directly use a service without excluding it from the DNS or the Load Balancer. The CPolydorou.HostsFile module contains function to add, remove, comment and uncomment entries in the hosts file. Administrator permissions are required in order to modify the file, so Powershell has to be run with elevated rights. You should also have .NET 4.5 installed. More information about the module can be found here, along with installation instructions.

Group Policy Processing and MS16-072

Today I'll talk about a change in the group policy processing design that troubled me today. I created a new GPO, configured the settings and the security filtering in order to restrict it to a test users group and then linked in to the domain. The policy however did not apply to all of the users in security group. I started by running gpresult in order to get the status of the GPO for the users on their computers. The GPO was inaccessible. I then double checked the permissions on the GPO just to make sure that the filtering has applied the correct permissions and that there were no deny permissions. Everything was good so far. I fired up the event viewer on the client computer in order to check the events regarding the group policy processing but there were not events regarding my GPO. After a quick check on the SYSVOL and ADSIEdit, I decided to focus on the client side since the GPO applied to some of the users in the security group and discovered the following. Recently, the