Tag Archives: PowerShell

How to Force ‘Remove-Item’ to Delete Items and Suppress the Confirmation Prompt in Windows PowerShell

The Problem: In Windows Powershell, deleting items with Remove-Item causes a confirmation prompt to stop a script from functioning. The prompt says: Confirm The item at [path] has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Areyou sure you want to continue? [Y] Yes [...]

Automating the Modification of a Windows Process’s Affinity: the Wrong Ways and the PowerShell Way

I just built a workstation that runs an ongoing set of computations on Windows 7 Professional x64. A main program spawns one process for each physical and virtual core as well as each GPU. I have a hyperthreaded four-core i7 which makes for eight total cores and thus eight individual processes. I also have a [...]

Solved: “The length of the property is too long. The maximum length is 2 and the length of the value provided is n”

The error “The length of the property is too long. The maximum length is 2 and the length of the value provided is n” is encountered when performing an action on an Active Directory user object within the Exchange Management Shell. Short Answer: Check to see if you have passed an invalid value to one [...]

Display a file’s size in kilobytes using Windows PowerShell

You’d think this wouldn’t be that hard of a task. However, I spent about an hour wading through misinformation and poor code snippets to figure this out. To determine a file’s size from within PowerShell, use the following snippet: $var = Get-Item [filename] $var.length In my specific case, I used: $file = Get-Item .\g2mdlhlpx.exe $file.length/1KB [...]