header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Search
Search Area
Criteria Options
Search Topics From
Search By User
Search in Forum(s)
Included Forums: ALL
Topic
RE: error with foreach/foreach-object
No sweat. Earlier releases of PrimalScript did make that replacement - I asked them to make it an exception because of this very issue.
by Don Jones in General PowerShell on 19 Jun 2008 10:40 AM
RE: error with foreach/foreach-object
BTW, as a rule I tend to either use ForEach-Object or % in pipelines. If I'm in a script, I just use foreach. Helps me keep it straight in my head.
by Don Jones in General PowerShell on 19 Jun 2008 10:32 AM
RE: error with foreach/foreach-object
Well, it's confusing for sure. foreach is an alias to ForEach-Object - but when it's used in the pipeline it uses the same syntax: $collection | ForEach-Object { $_.something() } $collection | foreach { $_.something() } Are both valid. Whe ...
by Don Jones in General PowerShell on 19 Jun 2008 10:31 AM
RE: error with foreach/foreach-object
(BTW, what you're seeing are some parsing tricks, and the help doesn't make this at all clear - foreach is intended to be used in the way foreach works in C#; foreach-object is a cmdlet intended to be used in pipeline one-liners, for example)
by Don Jones in General PowerShell on 19 Jun 2008 10:27 AM
RE: error with foreach/foreach-object
ForEach-Object doesn't use that syntax - it is not a replacement for ForEach. $URLs | ForEach-Object { $_.whatever() } works. You can only use the "$x in $y" syntax as in your first example.
by Don Jones in General PowerShell on 19 Jun 2008 10:26 AM
RE: What would be the best solution...
I think the -property parameter of Compare-Object will accept multiple properties. Honestly, if the files are supposed to be IDENTICAL, you could just... Diff (dir x:\ -recurse) (dir y:\ -recurse) It'll compare every property of each file/ ...
by Don Jones in General PowerShell on 04 Jun 2008 08:31 AM
RE: Error with WMI
Actually, I wasn't reading your syntax correctly :). This worked on my system: $disks = gwmi win32_logicaldisk $disk = $disks[1] # This is my C: drive $disk.volumename = "TEST" $disk.put() This is on a Win2008 system, against the local s ...
by Don Jones in General PowerShell on 27 May 2008 11:20 AM
RE: Error with WMI
Generally, you don't try to change the name of the property itself. You call Put() with the name of the property you want to change, and the new value. [edit] Correction, sorry, I was thinking ADSI. That should work - is this a remote system? What v ...
by Don Jones in General PowerShell on 27 May 2008 11:21 AM
RE: Error Checking in script dealing with network computers
You've really only got a couple of choices. You could ping the computer first - assuming your computers are normally pingable, that'll tell you if it's on the network or not and is a pretty quick test. But it won't tell you if WMI is working and ava ...
by Don Jones in General PowerShell on 25 May 2008 05:52 AM
RE: Works manually but not as a scheduled task
When you run the script manually, is Windows prompting you for a password or anything via a pop-up (I'm guessing not)? This is almost surely some kind of security-related issue - tough to troubleshoot, for sure. It may be something requiring the pre ...
by Don Jones in General PowerShell on 23 May 2008 01:23 PM
RE: Noob question on SqlReader Problem
Prior to executing Read(), look at the reader's HasRows property. What's it telling you? Also, while in debug mode, can you execute $r.Read() and get True back, or does it immediately return False? Has *anything* changed on the database server, p ...
by Don Jones in General PowerShell on 22 May 2008 11:36 AM
RE: Formatting default cmdlet output
Although you can't really do default formatting for a PSObject. Your cmdlet needs to define a new class and output objects of that class. This is all because the formatting subsystem relies on the object's type name to apply formatting; if you're us ...
by Don Jones in Cmdlet Development on 22 May 2008 11:31 AM
RE: Get-Content Foreach Output issue
Incidentally, my suggestion only works because the WMI class you're using happens to have a property that contains the computer name. Let's say you were doing this with a service, though - then it's tougher. There are a few ways to do it, but this o ...
by Don Jones in General PowerShell on 29 Feb 2008 01:07 PM
RE: How do you post colorized scripts?
FYI: Quick Reply doesn't provide the full range of formatting options - it's intended for "quick," one-off replies that don't need formatting.
by Don Jones in General PowerShell on 29 Feb 2008 01:00 PM
RE: Get-Content Foreach Output issue
Just add more properties to select-object. DNSHostName or Name, for example. Select-Object DNSHostName,SystemType
by Don Jones in General PowerShell on 29 Feb 2008 12:58 PM
RE: What's the trick to use {code} {/code}
The stars are part of the rating system. They don't come off - wouldn't be fair for someone to be able to remove a bad rating :).
by Don Jones in Testing, Testing... on 29 Feb 2008 12:57 PM
RE: PowerShell development book by Wrox
This is quite a good book. Short, but to the point. We're working on creating a PowerShell Development instructor-led class around it for this summer or fall.
by Don Jones in Cmdlet Development on 21 Feb 2008 06:09 AM
RE: Recommendations for training materials
www.scriptinganswers.com/training/courseware. Or you can contact training@sapien.com. It's packaged courseware that trainers can purchase - it's the same stuff I use in my public and private classes and it is based on "Windows PowerShell: TFM (2nd E ...
by Don Jones in General PowerShell on 13 Feb 2008 11:25 AM
RE: Fourums: formatting scripts - Help Requested
This is code Great!
by Don Jones in Community Announcements and Assistance on 13 Feb 2008 09:44 AM
RE: What's the trick to use {code} {/code}
http://www.activemodules.com/Community/tabid/55/forumid/115/tpage/1/view/topic/postid/40876/Default.aspx#40876
by Don Jones in Testing, Testing... on 08 Feb 2008 08:15 AM
RE: What's the trick to use {code} {/code}
If Code Then Depends on the language you're looking to have it format.
by Don Jones in Testing, Testing... on 08 Feb 2008 08:15 AM
RE: Fourums: formatting scripts - Help Requested
Use code and /code in angle brackets, as if they were HTML tags.
by Don Jones in Community Announcements and Assistance on 08 Feb 2008 08:13 AM
RE: Running .ps1 as Service
PowerShell is definitely not designed or tuned to be run as a service - you'd likely be disappointed. I agree that a schedule task is probably the best way to go. If you wanted to create a service that performed well, you'd need to use C# or Visual ...
by Don Jones in General PowerShell on 05 Feb 2008 06:55 AM
RE: .split()
A regex could probably be a better way to do this, especially if your URLs all start with http://. YOu'd just do something like (typing out loud here, so it'll probably not be exact) "http://\w*" as a regex to find everything starting with http:// a ...
by Don Jones in Working with .NET on 05 Feb 2008 06:53 AM
RE: Menus
I haven't seen anything for a text-based menu, but I imagine you could pilfer some code from PowerTab if you wanted to. You could also do graphical stuff in Windows Forms easily enough - I did a chapter on it in PowerShell: TFM (2nd edition). A simp ...
by Don Jones in General PowerShell on 30 Jan 2008 09:10 AM
Online Training
I'm really trying to get a handle on some online training ideas... I have a survey up; http://blog.sapien.com has information. Would really appreciate anyone who'd like to offer some feedback. Even if you're not interested in online training, feel f ...
by Don Jones in General PowerShell on 30 Jan 2008 09:07 AM
RE: Trapping warnings
Unfortunately right now the BEST solution (don't laugh) is to write a custom host app, and override the implementation of WriteWarning so that it goes to a file or something, not the console. That's the only way to selectively redirect the other pip ...
by Don Jones in General PowerShell on 30 Jan 2008 06:56 AM
RE: SQL Query
BTW, I like the way you were writing your SQL query to the console to verify it. Good idea. However, consider using Write-Debug instead. That way you can leave the command in your script and shut off the debug pipeline using $DebugPreference.
by Don Jones in General PowerShell on 30 Jan 2008 06:51 AM
RE: How do you insert and Aatar into your profile?
When you click "Edit Profile," you're taken to a consolidated page that has an "Avatar" section. Looks like you found it :).
by Don Jones in Community Announcements and Assistance on 18 Jan 2008 07:46 AM
Blogs
In a "dis-improvement," the DNN blogging functionality within the community is broken. Right now, none of the in-community blogs are accessible. For the moment, the concensus seems to be that bloggers will need to set up and maintain their ...
by Don Jones in Community Business on 18 Jan 2008 07:43 AM
Page 1 of 512345 > >>
Active Forums 4.3
right
footer   footer
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
footer   footer