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

what does the @ character do in scripts
Last Post 26 Oct 2008 03:34 PM by halr9000. 9 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
SynJunkieUser is Offline
New Member
New Member
Posts:97
Avatar

--
11 Oct 2008 02:33 PM  

occasionally i see the @ character used in scripts but i'm unsure what it is used for.  could anyone explain this please.

 

Thanks

Lee

marco.shawUser is Offline
Co-Community Director
Basic Member
Basic Member
Posts:188
Avatar

--
11 Oct 2008 03:15 PM  
These are all the examples I can think of quickly:

PS>$my_array=@() <--an array
PS>$my_hashtable=@{} <--a hashtable
PS>$my_here_string=@" <--a HERE string
>> some_text
>> "@
>>
PS>

So, "@" can be used in various constructs.
Marco

*Microsoft MVP - Windows PowerShell: http://www.microsoft.com/mvp
*PowerGadgets MVP: http://www.powergadgets.com/mvp
*Blog: http://marcoshaw.blogspot.com
SynJunkieUser is Offline
New Member
New Member
Posts:97
Avatar

--
21 Oct 2008 01:37 PM  
Thanks Marco. That helps. I'll have play around and get my head around it properly.

Cheers

Lee
edm365f31User is Online
New Member
New Member
Posts:38
Avatar

--
21 Oct 2008 02:41 PM  
Marco - I did not get this? So what is @ is it an alias for a cmdlet, what is it called and what does it do?
Thanks
Ed
halr9000User is Offline
PowerShell MVP, Site Admin
Basic Member
Basic Member
Posts:334
Avatar

--
21 Oct 2008 02:44 PM  
In version 1, it is _part_ of two operators, the array operator and the hashtable operator.

array: @()
hashtable: @{}

In version 2, there will be an additional meaning which I won't go into here because it won't clarify anything. :)
Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast
Author, TechProsaic
halr9000User is Offline
PowerShell MVP, Site Admin
Basic Member
Basic Member
Posts:334
Avatar

--
21 Oct 2008 02:44 PM  
Maybe construct is a better word than operator.
Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast
Author, TechProsaic
glnsizeUser is Offline
Basic Member
Basic Member
Posts:101

--
21 Oct 2008 11:16 PM  

Posted By halr9000 on 10/21/2008 6:44 AM

In version 2, there will be an additional meaning which I won't go into here because it won't clarify anything. :)

tease...

 

halr9000User is Offline
PowerShell MVP, Site Admin
Basic Member
Basic Member
Posts:334
Avatar

--
22 Oct 2008 12:47 AM  
here ya go, its called splatting.
Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast
Author, TechProsaic
glnsizeUser is Offline
Basic Member
Basic Member
Posts:101

--
26 Oct 2008 01:01 AM  

That is cool, but isn't that still a hashtable?  It seams to me the only real difference is that powershell will unwrap the name value pairs and pass them to the cmdlet.  The construct doesn't appear to be taking a new form.

Thanks

~Glenn

halr9000User is Offline
PowerShell MVP, Site Admin
Basic Member
Basic Member
Posts:334
Avatar

--
26 Oct 2008 03:34 PM  
Precisely. I anticipate using this a lot, too.
Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast
Author, TechProsaic
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