Update : version 0.992 now available including DFS-r
Hot on the heals of my AD sites module, I have been looking at some file system functions. This module is driven primarily by my own needs, but after a prompt on the powergui website from someone after a way of managing DFS with powershell (thanks packetboy), this is what I have come up with. All help files are included with examples, but I will publish the help and examples over time.
Requirements
This module has been built on a Windows 2008 R2 platform and therefore the DFS functions will be based around the 2008 R2 version of DFSUTIL. This is not to say that it is not compatible with anything earlier, it has just not been tested.
Installation and use
Download the zip file and extract to your modules folder. This can be found by running "explorer $pshome\modules" from a PowerShell console. To use, run "import-module Filesystem"
Command list and Help
To retrieve the list of commands and get help, as with all PowerShell functions and cmdlets use the built in get-command and get-help.
Get-command -module filesystem will list all the commands from the module
Get-help get-dfsroot -full will display the full help file
Included functions
add-DFSlinkABEPermission
add-DFSLinkTarget
add-DFSRootTarget
Add-NTFSPermission
disable-DFSLinkTarget
disable-DFSrootABE
enable-DFSLinkTarget
enable-DFSrootABE
get-DFSLink
get-DFSlinkABEPermission
get-dfsroot
get-DFSRootABEStatus
get-shareConnection
new-DFSLink
new-DFSroot
new-FileShare
remove-DFSLink
remove-DFSlinkABEPermission
remove-DFSLinkTarget
remove-DFSRoottarget
Remove-NTFSPermission
set-ntfsInheritance
set-sharepermission
test-fileshare
Please let me know any feedback in the comments, and of course, test in a development environment before using in production.
The module can be downloaded here.
cheers
Adam
Hot on the heals of my AD sites module, I have been looking at some file system functions. This module is driven primarily by my own needs, but after a prompt on the powergui website from someone after a way of managing DFS with powershell (thanks packetboy), this is what I have come up with. All help files are included with examples, but I will publish the help and examples over time.
Requirements
This module has been built on a Windows 2008 R2 platform and therefore the DFS functions will be based around the 2008 R2 version of DFSUTIL. This is not to say that it is not compatible with anything earlier, it has just not been tested.
Installation and use
Download the zip file and extract to your modules folder. This can be found by running "explorer $pshome\modules" from a PowerShell console. To use, run "import-module Filesystem"
Command list and Help
To retrieve the list of commands and get help, as with all PowerShell functions and cmdlets use the built in get-command and get-help.
Get-command -module filesystem will list all the commands from the module
Get-help get-dfsroot -full will display the full help file
Included functions
add-DFSlinkABEPermission
add-DFSLinkTarget
add-DFSRootTarget
Add-NTFSPermission
disable-DFSLinkTarget
disable-DFSrootABE
enable-DFSLinkTarget
enable-DFSrootABE
get-DFSLink
get-DFSlinkABEPermission
get-dfsroot
get-DFSRootABEStatus
get-shareConnection
new-DFSLink
new-DFSroot
new-FileShare
remove-DFSLink
remove-DFSlinkABEPermission
remove-DFSLinkTarget
remove-DFSRoottarget
Remove-NTFSPermission
set-ntfsInheritance
set-sharepermission
test-fileshare
Please let me know any feedback in the comments, and of course, test in a development environment before using in production.
The module can be downloaded here.
cheers
Adam
Thanks. Just what I was looking for. Works nicely.
ReplyDeleteThis is really really useful thank you. One comment though - it appears from my early testing that since you're picking up the $env:USERDOMAIN value and referencing it as $netbiosdomain, then using that as a reference on the "object" parameters for adding / removing NTFS permissions, you can't specify for example, the builtin\users group to act upon?
ReplyDeletehaving said that, commenting out the $userdomain argument and its comma within the argumentlist parameter of the ntaccount class does the trick, just means you need to specify the domain as part of the -object parameter
ReplyDeletethanks for the feedback. I will update the functions to allow for built in groups to be added.
ReplyDeletecheers
Me again - Following your lead, I've created equivalent DFSR functions to create replication groups, add members, add connections, add folders etc. Not quite as elegant as your DFSN / file services module but if you want the code to add to your module or to update and publish as you see fit, you're welcome to it, after all the work you saved me by making your module available.
ReplyDeleteThank you, works very well, the only way I found to get a decent formatting when listing DFS targets. You might consider changing the module-name from filesystem to something more unique, I already had another module named filesystem, I suspect it is common.
ReplyDeleteWhat I've seen so far is awesome, however the get-dfslink cmdlet doesn't return the entire link name when it contains a space (I inherited it, and I'm not the senior SysAdmin...)
ReplyDeleteThank you,
Actually the Get-DFSLink cmdlet doesn't seem to like spaces either. It seems to be returning the correct information, but it throws a "You cannot call a method on a Null-Valued Expression" error for each space in the path, even when encased in single or double quotes.
ReplyDeleteOn the plus side, it is handling the ridiculous number of "&" characters like a champ (I have a single path with 4 '&' Characters)!
A minor thing, for anyone doing the wierd things I am, Get-DFSLink seems to return a Hash or Array for the Targets, which is fine, however, the 'State' Property of the Targets Noteproperty for a disabled Target is returned as "disbled" so, if like me you are filtering out disabled targets, make sure you are checking for "disbled". It might be good to note that I think I'm using Version .95 not .94
ReplyDeleteThanks for the great feedback, I'll update in the next couple of days.
ReplyDeleteanon - where can we get the DFSr files you made?
ReplyDeleteAnother big thank you for this useful module. Can I suggest you rename Process-FixedWidthText to Format-FixedWidthText to get rid of the unapproved verb warning.
ReplyDeleteHopefully you are still active on this blog. I'm using your module, and I'm very happy so far, but I cannot figure out how to return, all the namespace server of a specific name space.
ReplyDeleteCan you help ?
Seems that you have found a bug....the get-dfsroot command should output the namespace servers in the targets attribute.
DeleteThanks for the feedback :)