Monthly Archives: September 2015

Uploaded CustomizeWindows10 Module to PowerShell Gallery

Today I finished another major update to the CustomizeWindows10 module I have been working on together with Jan Egil Ring. This module started as a means for me to configure/tweak Windows 10. When I was experimenting with the various Windows 10 insider builds I found myself configuring the same settings on each deployment and I was looking to simplify this process. The module contains a number of tweaks and configuration options to customize and personalize the Windows 10 experience.

CustomizeWindows10-0.0.0.4

In the past I have uploaded the majority of my scripts and functions to the TechNet Script Gallery, but recently I have started using GitHub as a version control system for my scripts. Eventually I plan to upload my entire collection of scripts to GitHub as it provides the opportunity for easier interaction with a wider community but for now this module is my first experiment with both the PowerShell Gallery as well as GitHub.

The module consists of both a PowerShell module as well as a DSC module to allow complete flexibility when applying these settings. In the following example the module will be used to ensure that hidden files are visible and that file extensions are always shown:

1
2
3
4
Import-Module -Name CustomizeWindows10
Enable-ShowFileExtension
Enable-ShowHiddenFiles
Get-ShowHiddenFiles

CustomizeWindows10-CodeExample

For more information or the direct download links of these scripts please refer to the links below. Feel free to leave a comment either here or to contribute directly on GitHub.

TechNet Script Gallery
My entries in TechNet Script Gallery
Blog.PowerShell.No – Jan Egil Ring
JaapBrasser.com – Scripts
GitHub – CustomizeWindows10
PowerShellGallery – CustomizeWindows10
TechNet Script Gallery – CustomizeWindows10

 

Share

Active Directory Friday: Find groups with no members

Occasionally groups may become obsolete or are never populated with members. It can be interesting to find out how many groups are in your organization that have no members, as action can be taken on it based on the output.

Overview of articles in this series
Active Directory Friday: Find groups with no members
Active Directory Friday: Principal group membership
Active Directory Friday: User account group membership

Because of the nature of how group membership is defined this article will be the first in a series of three. In this article I will show how group membership can be determined using an LDAP queries. The next article in this series will go into principal group membership and its implications and the final article will go into constructed attributes and how to work with constructed attributes, specifically the memberof attribute.

In this article I will give a a number of examples that can be used to determine which groups are empty. Using Get-ADGroup the following command can be executed to retrieve memberless groups:

Get-ADGroup -LDAPFilter '(!(member=*))'

Get-ADGroupNotMemberAnything

Alternatively the DirectoryServices.DirectorySearcher object can be used to achieve a similar result:

(New-Object DirectoryServices.DirectorySearcher -Property @{
 Filter = '(&(objectClass=group)(!(member=*)))'
 PageSize = 100
}).FindAll()

The [adsisearcher] type accelerator is another interesting alternative for this purpose, here is an example:

([adsisearcher]'(&(objectClass=group)(!(member=*)))').FindAll()

The problem with the above examples however, is that some groups will show up as being empty, for example the Domain Users group. Next week I will go into Principal group membership, what this is and how to query for this and by doing so generate more accurate results in regards to group membership.

For more information about the topics discussed in this article, please have a look at the following resources:

Active Directory Friday: Find groups with no members
Get-ADGroup
JaapBrasser.com – Active Directory Friday
Free ebook – Active Directory Friday All Articles
DirectoryServices.DirectorySearcher
Share

Get-RecycleBin – Shows the contents of the Recycle Bin

As I posted earlier in the Clear-RecycleBin New PowerShell 5.0 cmdlet, available in Windows 10 article, in Windows 10 it is now possible to clear the Recycle Bin. Because the functionality to actually view which files is not implemented in any cmdlet at the moment I decided to upload a new function, Get-RecycleBin, to the TechNet Script Gallery.

Get-RecycleBin

Using the this function it is possible to view the contents of the recycle bin, including the filename, size and the current path in the Recycle Bin folder.

.EXAMPLE
Get-RecycleBin

Description
-----------
Executing this function will display the name, size and path of the files stored in the Recycle Bin for the current user

For more information or the direct download links of these scripts please refer to the links below. Feel free to leave a comment either here or in the TechNet Script Library.

TechNet Script Gallery
My entries in TechNet Script Gallery
JaapBrasser.com – Scripts
Get-RecycleBin – shows the contents of the Recycle Bin
Share

New versions of scripts and a new script in the TechNet Script Gallery

After attending the PowerShell Conference Asia this weekend in Singapore I realized I did not update my scripts in the TechNet Script Gallery for a while, so I took some time to go through the feedback and feature requests for my scripts. I found out that there was some work to be done on a number of my scripts and I got started with it.

First of all I started with the The Get-ScheduledTask script, I added in the ComputerName from which the tasks are gathered in the output. This was done to ensure that the script functions as expected when used in combination with the Remove-ScheduledTask script. Additionally I also included the triggers in the output as requested by Profile787.

Get-ScheduledTask

The Remove-ScheduledTask script is able to remove scheduled tasks and supports pipeline input from the Get-ScheduledTask script:

.EXAMPLE 
Remove-ScheduledTask -ComputerName JaapTest01 -Path '\Folder\YourTask' 
 
Description 
----------- 
Will remove the YourTask task from the JaapTest01 system 
 
.EXAMPLE 
.\Get-ScheduledTask.ps1 | Where-Object {$_.State -eq 'Disabled'} | Remove-ScheduledTask -WhatIf 
 
Description 
----------- 
Get-ScheduledTask will list all the disabled tasks on a system and the Remove-ScheduledTask function will list all the actions that could be taken

Get-OrphanHomeFolder, there were two requests for new functionality and because of that I introduced two new parameters:

  • SearchBase
  • CheckHomeDirectory
.PARAMETER SearchBase
This parameter determines what the SearchBase for the AD query is, the LDAP path for an OU should be specified here. This can be used to limit the AD Query to a sub tree within Active Directory

.PARAMETER CheckHomeDirectory
Setting this switch parameter will check the full path of the folder against the HomeDirectory attribute of an ADObject, when using this switch make sure that the correct shared folder or DFS path is used, otherwise output can be unreliable

.EXAMPLE 
.\Get-OrphanHomeFolder.ps1 -HomeFolderPath \\Server01\Home -SearchBase 'LDAP://OU=YourOU,DC=jaapbrasser,DC=com'

Description:
Will list all the folders in the \\Server01\Home path. For each of these folders it will query AD, only in the YourOU Organizational Unit of the JaapBrasser domain, using the foldername

.EXAMPLE 
.\Get-OrphanHomeFolder.ps1 -HomeFolderPath \\dfs\share\userfolders\ -CheckHomeDirectory

Description:
Will list all the folders in the \\Server02\Fileshare\Home folder and check against the homedirectory attribute of the AD objects

The Get-UnchangedPwdlastset script has also been updated, as one of the default values was being added instead of subtracted from the result as noted by Richard Mueller.Finally the last script that has been updated is the Get-LoggedOnUser script. Apaladi correctly noted that with certain regional datetime settings it would be possible for the script to truncate the data incorrectly.

For more information or the direct download links of these scripts please refer to the links below. Feel free to leave a comment either here or in the TechNet Script Library.

TechNet Script Gallery
My entries in TechNet Script Gallery
Get scheduled tasks from remote computer
Remove Scheduled Tasks from remote computer
Script to get orphaned home folders and folder size
Query for AD Users that have not changed password for x-days
Get-LoggedOnUser Gathers information of logged on users on remote systems
Share

PowerShell Conference Asia 2015 Day 2 – The conclusion to a great event

PSConfAsiaSponsors

After the second day the PowerShell Conference Asia in Singapore unfortunately concluded. I have collected a number of photos both from Twitter as well as from my own camera and made them available here for other attendees of the event.

I would like to give a big shout-out to Milton Goh, Matthew Hitchcock, Ravikanth Chaganti and Benjamin Hodge for putting this event together with the support of the sponsors of the event. It was a great opportunity for myself to interact with the PowerShell community in Asia and I thoroughly enjoyed it.

 

For more information here are the links to the PowerShell Conference Asia site and to the Twitter hashtag:

PowerShell Conference Asia 2015 Day 2
PowerShell Conference 2015
#PSConfAsia
Share

PowerShell Conference Asia 2015 Day 1 – A Picture is worth a thousand words

PSConfAsiaSponsors

Today I had the pleasure to attend the first ever PowerShell Conference Asia, hosted by Microsoft in Singapore. I took a number of photos from the event and retrieved a number of photos uploaded to Twitter to give an impression of the event.

I would like to thank everyone attending the event, you are a great crowd and I am looking forward to another great day tomorrow. For now enjoy the photos:

 

For more information here are the links to the PowerShell Conference Asia site and to the Twitter hashtag:

PowerShell Conference Asia 2015 Day 1
PowerShell Conference 2015
#PSConfAsia
Share