Monthly Archives: May 2014

File system ACLs–function to add ACL

I thought that today I’d start putting together a function to add an ACL to a file system object. The starting point is the code that stepped through the process in an earlier post: http://msmvps.com/blogs/richardsiddaway/archive/2014/05/26/file-system-acls-creating-an-acl.aspx function add-acl {[CmdletBinding()]param ( [Parameter(Mandatory=$true)] … Continue reading

Posted in File system, Powershell | Leave a comment

PowerShell Scripting Best Practices

Ed Wilson is running a series on Best Practices on his Hey, Scripting Guy blog at the moment.  I especially like today’s which is on simple scripts.  I do a lot of quick and dirty scripts that end up being … Continue reading

Posted in Powershell, Powershell Basics | Leave a comment

File system ACLs – copying ACLs

A comment was left on the first post in the series asking if I could show how to copy ACLs from one object to another.  For the sake of this post we’ll assume that the ACLs from c:\test will be … Continue reading

Posted in File system, Powershell | Leave a comment

File System ACLs – creating an ACL

Last time you saw that the permissions assign to a file system object are built from instances of the System.Security.AccessControl.FileSystemAccessRule class.  Run Get-Acl -Path c:\test | fl * and look at the Access property. Drilling into an individual ACL they … Continue reading

Posted in File system, Powershell | Leave a comment

File System ACLs – Get-Acl #1 – Retrieving permissions

Following on from the recent set of posts about setting security permissions on shares I thought it about time I looked at the file system security permissions. PowerShell supplies 2 cmdlets, in the core engine, Get-Acl and Set-Acl for workign … Continue reading

Posted in File system, Powershell | 2 Comments

Remove entry from trusted hosts list

The last variant I want to show is removing a single entry from the list function remove-trustedhost {[CmdletBinding()]param ( [string]$trustedhost, [string]$computername = $env:COMPUTERNAME) if (Test-Connection -ComputerName $computername -Quiet -Count 1) {  $th = Get-WSManInstance -ResourceURI winrm/config/client -ComputerName $computername |   … Continue reading

Posted in Powershell Basics | Leave a comment

Clearing the trusted hosts list

Sometimes you may just need to clear out all of the current values in the trusted hosts list and start again – especially in a lab environment where you may be experimenting. function clear-trustedhost {[CmdletBinding()]param ( [string]$computername = $env:COMPUTERNAME) if … Continue reading

Posted in Powershell Basics | Leave a comment