header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

question about [powershell]
Last Post 21 Nov 2008 03:58 AM by Elan. 5 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
ElanUser is Offline
New Member
New Member
Posts:28
Avatar

--
20 Nov 2008 09:37 PM  
I forgot what the pieces of code that are contained in [brackets].

For example, [datetime], [math], etc...  There seems to be so many it almost seems so difficult to know what you can code, especially from a newbie perspective.  Just curious on recommendations on how to deal with this from a newbie perspective other than looking things up when trying to do a specific thing and just getting used to it which I'm assuming is what I'll just have to do.  Figured I'd ask in case any of you guys know PowerShell links which list most commonly used ones for Exchange, AD, etc...

Thanks!
Elan Shudnow
http://www.shudnow.net
EBGreenUser is Offline
New Member
New Member
Posts:61
Avatar

--
20 Nov 2008 11:24 PM  
They are called type accelerators (or type shortcuts). There is a good list of them here:

http://blogs.msdn.com/powershell/archive/2006/07/12/663540.aspx
halr9000User is Offline
PowerShell MVP, Site Admin
Basic Member
Basic Member
Posts:334
Avatar

--
21 Nov 2008 02:50 AM  
You could actually go quite a ways and never use them. I recommend you pick up a book such as PowerShell: TFM by Don Jones & Jeff Hicks, PowerShell in Action by Bruce Payette, or the PowerShell Cookbook by Lee Holmes.

But I agree the subject needs more ink. Maybe we'll cover it in a future podcast.
Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast
Author, TechProsaic
ElanUser is Offline
New Member
New Member
Posts:28
Avatar

--
21 Nov 2008 03:42 AM  
Hey, I actually have all those books except for the TFM and have done about 5 or so decent scripts so far. I simply forgot the name. Thanks.

So taking a look at the example from the URL linked, I see:
[System.Text.RegularExpressions.Regex]"^c.*"
[Regex]"^c.*"

[Regex] is a shortcut. But where can I find more than what is specified in the article. For example, when I am looking for DCs in the forest, I know to use: [System.DirectoryServices.ActiveDirectory.Domain]. How would I have known that other than searching Google? Is [System.DirectoryServices.ActiveDirectory.Domain] even considered a Type accelerator/shortcut?

Or even let's say I need to create a new object such as System.Diagnostics.ProcessStartInfo. Where can I find what objects are out there to mess with. So if I wanted to script something, I wasn't trying to figure out what objects I can interact with to do what I need.

So hopefully I made my point clear that I am just looking to find easy ways to find out what objects or type accelerators such as [System.DirectoryServices.ActiveDirectory.Domain] are out there for me to utilize.

Thanks
Elan Shudnow
http://www.shudnow.net
meson3902User is Offline
New Member
New Member
Posts:12
Avatar

--
21 Nov 2008 03:47 AM  

Well these are all .NET types and I personally find MSDN to be the best source of information. Probably not the most efficient source for finding types to use, but I find it the best to find information about the type. To help you out I am including a script that I wrote (with some modification from others) that opens a web browser to the specific msdn page. For example you can just type

"find-msdn System.DirectoryServices.ActiveDirectory" to find the information you want.

 

 

function Find-MSDN
 {
 param( $Class,
 $DotNetVersion = "2.0",
 $Section = ""
 )
 switch ($DotNetVersion) {
  "1.1" { $VersionStem = "(VS.71)"; break}
  "2.0" { $VersionStem = "(VS.80)"; break}
  "3.0" { $VersionStem = "(VS.85)"; break}
  "3.5" { $VersionStem = ""; break}
 }
 switch ($Section) {
  "Members" { $SectionStem = "_members"; break}
  "Methods" { $SectionStem = "_methods"; break}
  "Properties" { $SectionStem = "_properties"; break}
 }
 $UrlFile = New-UrlFile "http://msdn2.microsoft.com/en-us/li...nStem.aspx"
 Invoke-Item $UrlFile |out-null
 Remove-Item $UrlFile
}

ElanUser is Offline
New Member
New Member
Posts:28
Avatar

--
21 Nov 2008 03:58 AM  
Thanks. Ah I see, so they are types. That makes sense so there are a limited amount of type shortcuts and the longer ones such as [System.DirectoryServices.ActiveDirectory] are regular types. Now I get that piece. I should have known that but I was agressively learning PowerShell for a month and then I got really busy at work for a month and a half and I forgot those were called Types.

I know there's a TFM AD book coming out, going to have to get that. Right now I'm trying to get through some Exchange PowerShell stuff.

Thanks.
Elan Shudnow
http://www.shudnow.net
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer