January 2009 - Posts
Interesting point. I still like ISA Server better though, but that’s me.
ISA Behind a Cisco ASA? « Richard Hicks’ ISA/TMG Blog
What if your CSV file doesn’t have headers? well Powershell makes that pretty easy too. Essentially you have to read in the text then split the text into the separate columns.
$users=@(); get-content test.csv | foreach-object {$users+=,($_.split(“,”));};
|
Once that command is done your $users variable will have each field in your CSV into a separate array element. Then you can do something like $users[0][0] to get the first item in the first row or $users[-1][-1] to get the last item in the last row.
Here is a related blog post on arrays
http://blogs.msdn.com/powershell/archive/2007/01/23/array-literals-in-powershell.aspx
Importing a CSV file will allow you to work with it as though it were an object. Here is an example
| get-process get-process | export-csv process.csv $process = import-csv process.csv $process $process | format-table $process | where-object {$_.vm -gt 100000} | Format-Table
|
Once imported the rows of the csv file become the objects you can manipulate. The column headings become the properties.
I have one question about this. I am all for fiscal responsibility, but how to you get things paid if people are not working? How do you give tax cuts to someone who is not paying any?
Let people get working first then give a cut that is fair when bills are paid. But that is me.
Obama recovery plan advances in Congress - Economy in Turmoil- msnbc.com
Windows PowerShell: Working with Active Directory
One thing I will say here. I was teaching a class and I had a brain fart. I couldn’t for the life of me remember how to add users to groups. Well one little nuance to the above script is adding multiple users requires you to do an assignment first. You do it in one of these two ways.
Method 1 $group=[adsi]”LDAP://path”; foreach-object ($user in $userarray) { $user; $null=$group.member.add($user); } $group.psbase.commitchanges(); |
or in this method we use the pipeline instead, however you have to assign it to a variable first.
Method 2 $group=[adsi]”LDAP://path”; $userarray | foreach-object { $user=$_; $user; $null=$group.member.add($user); } $group.psbase.commitchanges(); |
When it comes to working with PowerShell and ADSI, it is important to refer back to these two blog posts.
http://blogs.technet.com/benp/archive/2007/03/05/benp-s-basic-guide-to-managing-active-directory-objects-with-powershell.aspx
and
These that are related
http://pathologicalscripter.wordpress.com/2006/09/28/invisible-methods-for-adsi/
http://blogs.msdn.com/arulk/archive/2006/07/25/678137.aspx
http://blogs.msdn.com/arulk/archive/2006/07/28/682289.aspx
http://blogs.msdn.com/arulk/archive/2006/08/24/719241.aspx
And when needing a reference to set values, here is the guide that showed which interface and what are the right fields in active directory.
http://msdn.microsoft.com/en-us/ms677286.aspx
This will work in powerShell as well. So you can install local printers using this interface. I have not tried it with Vista or Server 2008 but it seems like it is exactly what you need if you want to automate install of local printer.
Install Printers using Batch Files
Here are some samples of how you can add a network printer to a machine through WMI.
http://www.fpschultze.de/smartfaq+faq.faqid+263.htm
Adding network shared printer
Another example of using Powershell in ASP.NET. With this example there is more information on a simple page to test this.
www.leastprivilege.com - Hosting PowerShell in ASP.NET
If you want to put powershell into your applications or into ASP.NET then here is a sample of how you could host it within your site.
Windows PowerShell Blog : Impersonation and Hosting PowerShell
These are some neat features.
Interesting joke about the Siamese fighting fish. Not sure if that is the only joke, but this is the one I got out of it.
Tim Sneath : The Bumper List of Windows 7 Secrets
More Posts
Next page »