Tuesday, September 29, 2009

More PowerShell

So I've been working more with PowerShell today... not on the creating a local user stuff that I should prolly focus more on, but other cool stuff you can do. I think all together I've got scripts now that can set printer permissions, set folder permissions, reboot the system, send emails, and plenty more. At the end of this are the scripts themselves for anyone to see and use. I'm currently working on one that will take the IP address of a computer and turn it into an SCCM variable. I thought I had it nailed down, but ended up I didn't. I think I've since corrected the issue, and I'm currently testing it in a Hyper-V virtual machine to find out. That will prolly come tomorrow.

I came across an interesting article today. It is basically saying that disc encryption isn't as secure as people thought. Pretty interesting.... makes me love the fact that the government has my information on laptops with encryption like this.
http://www.wired.com/threatlevel/2008/02/researchers-dis/

Also found this, it's nice to see.
http://www.wired.com/threatlevel/2009/08/churchill/

Last but not least, I found this. I haven't tested it or played around with it, but it looks as if it's free antivirus software from Microsoft as long as you have a legit copy of Windows.... I have a non-profit I work with that might be interested in this....
http://www.microsoft.com/security_essentials/


The Scripts
Setting Printer Permissions
gwmi -class Win32_Printer -comp ServerName | % { $_.Name} | % { subinacl.exe /printer \\ServerName\$_ /grant=DomainName\GroupName=F}
# F means full control
# M means manage
# P mean print

Setting folder permissions
 $acl = Get-Acl c:\temp
$permission = "domain\user","FullControl","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
$acl | Set-Acl c:\temp

Reboot a system
$server = gwmi Win32_operatingsystem -computer Your_Servername
$server.reboot()

## to know what else is availabe run the following
# $server | get-member

Send an email
$SmtpClient = new-object system.net.mail.smtpClient
$SmtpServer = "YOUR_SERVER_IP"
$SmtpClient.host =
$SmtpServer


$From = "FROM_ADDRESS"
$To = "SEND_TO"
$Title = "SUBJECT"
$Body = " BODY_OF_EMAIL"
$SmtpClient.Send($from,$to,$title,$Body)  


 
 
Enjoy

No comments: