19h
asked Select substring up until second underscore in SQL
Feb
26
awarded Popular Question
Feb
24
asked Trying to replace chars in csv, then write modified file to filesystem
Feb
24
accepted How to omit empty strings in output
Feb
24
comment How to omit empty strings in output
Thanks, but trying this on the commandline (Get-Content .\BSEG_EXPORT.csv | foreach { $cell = $_.Split(",")[6] if ($cell -ne "") { Write-Host $cell } }) gives me an error: Unexpected token if. I can probably put it in a .ps1 and it'll work, but how do I formet this for the command line?
Feb
24
asked How to omit empty strings in output
Feb
16
awarded Popular Question
Feb
16
awarded Notable Question
Feb
10
comment Error handling in SQL Server wrapper
Ah yes. However, this tool is for internal use only. I'm trying to build a usefull library of functions that I might need every now and then...and in the mean time learn about PS. So putting security risks aside for now (I could also make the error message less instructive), could you get me started on getting some proper error handling in there?
Feb
10
comment Error handling in SQL Server wrapper
I don't understand. Could you elaborate? AFAIK I need to build a connection string first, to connect to the database, no?
Feb
10
asked Error handling in SQL Server wrapper
Feb
6
comment Counting number of files in dir returns 0 when there is only 1 file match?
Works great, but I fail to see why. In my version, I count the number of files in a folder using cgi and cast the result as a number. I agree that in doing so, the .count property (method?) is not available. But if cgi returns say 128 files, the script outputted 128 (even though 128.count doesnt make sense). But why didn't this work for a folder with 1 file? Basically it woud return [int]1.count which should still be 1, right? Why did my script work for all number of files in a folder, but not for 1?
Feb
6
accepted Counting number of files in dir returns 0 when there is only 1 file match?
Feb
6
asked Counting number of files in dir returns 0 when there is only 1 file match?
Feb
6
accepted How to get leading spaces instead of zeros in Powershell?
Feb
5
comment Count number of files in each subfolder, ignoring files with certain name
Unfortunately, have to deal with an environment where I have no control over. Anyway, thanks for all your responses!
Feb
5
comment Count number of files in each subfolder, ignoring files with certain name
Thanks a lot. One question however: if I run this in V3, The table from left to right has the columns FolderName ItemCount but running the same in V2 outputs the table as Itemcount Foldername ?! Putting the Itemcount in the line above Foldername in the $ObjectProperties in the script does not change this. What is causing this behavior? BTW Is it me or are the differences between V2 and V3 just very annoying? V2: Format-Table -Auto, V3: Format-Table -AutoSize Sigh :-)
Feb
5
comment Count number of files in each subfolder, ignoring files with certain name
The result is like Name Value ---- ----- Items 260 Folder TEXT0001 Items 14 Folder TEXT0001_skip Items 143 Folder TEXT0001_trans1_exported Items Folder TEXT0001_trans2_exported Items 81 Folder TEXT0001_trans3_exported Items Folder TEXT0001_trans4_exported @1RedOne Any way to make it backwards compatible?
Feb
5
comment Count number of files in each subfolder, ignoring files with certain name
This is awesome, and it works like a charm on my Windows 8 machine, but it does not work as expected on my server (which runs PS 2). The code is Function Filecount { param ( [string]$dir, [string]$ignore ) Get-ChildItem -Path $dir | Where {$_.PSIsContainer} | Sort-Object -Property Name | ForEach-Object { [pscustomobject]@{ Folder = $_.Name; Items = (Get-ChildItem -Recurse -Exclude "*$ignore*" -Path $_.FullName).count } } } Filecount -dir "C:\ROOT" -ignore "translated_by" | Format-Table -AutoSize
Feb
5
asked How to get leading spaces instead of zeros in Powershell?
1 2 3 4 5