377 reputation
1423
bio website stackexchange.com/users/…
location England
age 38
visits member for 1 year, 9 months
seen Jul 3 at 11:37

profile for SteB on Stack Exchange, a network of free, community-driven Q&A sites
Disclaimer: I like to wait at least an hour before accepting an answer.

Software developer, sci-fi and film/TV fan working on LOB apps using Delphi, T-SQL, PHP, HTML, CSS and Powershell.

I like to relax with good films, TV or books including: The Matrix, Underworld, Stargate, Buffy, The West Wing, and works by Joss Whedon, Ridley Scott, David Weber or Peter F. Hamilton.

In my spare time I assist with the browser-based football game Football Glory.


Dec
13
comment Protect foreach loop when empty list
I've used the first one (it's easier to understand), I couldn't get the second one to work (I was probably doing something wrong).
Dec
13
comment Protect foreach loop when empty list
@Dan - Doh, can't believe I didn't spot that, thanks.
Dec
13
comment Protect foreach loop when empty list
@Dan - Tried both ($backups > 0) and (@($backups).count -gt 0), but neither work as expected when there are no files.
Dec
13
comment Protect foreach loop when empty list
$count = @($backups).count; almost works, but when there are no files if f($count -gt 0) is true!
Dec
13
comment Protect foreach loop when empty list
Adding if ($backups.count -gt 0) stops the loop executing even when there's 1 item in $backups. $backups.count even on it's own doesn't output anything.
Dec
12
comment Powershell enters foreach loop with null object
It appears that I'm only running v2 (I used $psversiontable), I feel an upgrade coming on :) Thanks for your help.
Dec
11
comment Powershell enters foreach loop with null object
Yes, I am using PowerGUI. My powershell.exe in WindowsPowerShell/v1.0 is 6.1.7600.16385. $PSVersionTable gives CLRVersion: 4.0.30319.17929 and WSManStackVersion: 2.0
Dec
11
comment Powershell enters foreach loop with null object
I get an output of "Hi" and my $Host.Version gives 3.2.0.2237
Dec
10
comment Zipping only files using powershell
Sorry, it was my fault, I'd accidentally changed it to Test-Path-Path! That works great now.
Dec
10
comment Zipping only files using powershell
That looked good, but when I tried it nothing happened. I didn't get a zip file but I also didn't get any errors. Could you expand on what the Set-Content and ReadOnly = false lines do?
Dec
7
comment Zipping only files using powershell
@MDMarra - that works great, thanks. I've just realised that .Net 4.5 isn't supported on Server 2003! I might try calling a zip utility from the command-line, thanks for all your efforts.
Dec
7
comment Zipping only files using powershell
@MDMarra - Only up to 4, I'll install 4.5 and try again, thanks
Dec
7
comment Zipping only files using powershell
@MDMarra - I now get a "make sure that the assembly containing this type is loaded." error, I've tried "[System.AppDomain]::CurrentDomain.GetAssemblies()" but can't see a compression dll
Dec
7
comment Zipping only files using powershell
@MDMarra - Yes, powershell 3 (developed on Win7, deployed on Server 2003), isn't that what the "-com shell.application" does? Or have I messed that up?
Nov
2
comment Powershell delete files only from directory
This works (only delete files from specified directory, ignoring sub-dirs): Remove-Item "D:\MyTemp\*.*" | Where { ! $_.PSIsContainer }
Nov
2
comment Powershell delete files only from directory
This only lists file in the current directory
Nov
1
comment Powershell Directory.Name return the trailing separator?
I'm looking to delete everything in $Dir, files and sub-folders (and everything in those)
Nov
1
comment Powershell Directory.Name return the trailing separator?
To remove all files do you not do: Remove-Item $Dir +"*" -recurse? I thought you needed the \ to use the *?
Oct
19
comment Defrag in Windows VM?
Thanks, I'm primarily interested in the performance aspect.
Oct
8
comment Windows GPO default mapped drives
According to this it's not recommended