powershell

How can I delete LRU folders until 5GB free space is available

Given a folder \localhost\c$\work\ I'd like to run a powershell script every 15 minutes that ensures 5gb of free space is available. If < 5gb is available, remove the least recently used folder within work until >5gb is available. Gravy for nice output that can be redirected to a log file. Thoughts? ...

I can't find the typo in my syntaxhighlighter code. Can you spot it?

On my Blogger blog I have the following code exactly, but it doesn't work. Can anyone tell me what is wrong? <link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeRDark.css' rel='stylesheet' type='text/css'/> <script type='text/javascript'> SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.config.clip...

XPATH issue in C# and PowerShell

Hello everyone, I have the following XML file and I want to print out the baseAddress value, then change the value and write update to the same XML file. My problem is I am using the following scripts in PowerShell to manipulate, and seems the related value could not be retrieved. I think the reason may be there is a sign '.' in the el...

PowerShell manipulating XML file issue

Hello everyone, Suppose I have the following XML file, and I want to use PowerShell (version 1.0) to manipulate the XML file to get the value for Foo (in this sample, value I want to get is "Foo Value") and Goo (in this sample, value I want to get is "Goo Value"), any ideas how to implement? $FooConfig = [xml](get-content .\Foo.exe.con...

Is there a way in Powershell to provide virtual file systems in other file systems?

I know you can write support for custom PSDrives. But those are always a root of a file system. What would be nice if there was a way to allow for VFS start at arbitrary nodes of the file system, such as using Set-Location to enter archive file maybe and use them as if they were folders. (Kinda like Far does this). Is there any way to a...

What are the benefits of a Powershell script over a Console Application?

For some of monitoring applications and for tasks that are required to be scheduled to poll some service, we traditionally use a console application that in turn calls some methods in our business layer or polls file locations/ftp locations. For another task I was carrying out I started playing about with Powershell and was pretty impr...

How can i add endnotes to a word doc using Powershell?

Hello I'm looking for a way to search for a word in a word doc and add an endnote(special type of footnote) with a definition of the word as the endnote text. This would allow me to hover over that word and then the definition would pop up like a tool tip. I know i need to use reflection, but i'm new to the whole reflection thing and al...

how to get local host name in PowerShell?

Hello everyone, How to get local host (machine) name in PowerShell? I am using PowerShell 1.0. Thanks! regards, George ...

XML query against SQL Server SSIS DataProfiler xml file in Powershell does not work. Help?

Hi, I am trying to query out the attribute values from the xml file attached below. Specifically, I am trying to get the Name, SqlDbType etc. attribute values that are in the "Column" Element Node under"ColumnNullRatioProfile" Node. The xml output file comes as a part of the SQL Server 2008 SSIS DataProfiler Task. My goal is to use Pow...

Need command to get a file from TFS without a workspace

What I want to do is get a specific version of a file from TFS to a location other than my workspace using the command line (either tf.exe or powershell) I want to do this so that it doesn't affect the files in my workspace, and places the file into a release folder. tf.exe only seems to support getting a file to your workspace. I hav...

Path of currently executing powershell script

How do I do this in PowerShell. In a batch file I would do: %~d0%~p0 ...

Which versions of the Microsoft.NET framework work with Windows Powerhsell?

I am working on providers and cmdlets for Powershell 1 & 2. Which version(s) of the framework should I target for my extensions? I assume Microsoft.NET 2 will work fine. What about 3.0 and 3.5? Microsoft.NET 4.0? ...

PowerShell Runspace vs DLR

With the .NET 4.0 beta now available, and thus the wider availability of the .NET Dynamic Language Runtime, I guess these kinds of topics are going to become "hotter". I'm confused about the conceptual differences between the DLR and PowerShell. It seems to me that if I want to provide scripting capabilities in my .NET app, I can use...

How to Loop Datareader and create DataTable in Powershell

Hi, First of all let me thank those people that answered my previous questions. You guys are Awesome!!! Here is my question: I like to query my sql server Stored procedure and return a datareader. However I want to create a Table out of it. That table I will use to load excel using the new Powershell OpenXML commandlets. The code fails ...

Whats the best way to wrap a c# class for use by powershell script.

I have an engine that executes powershell scripts, and when they execute, need to feed back in some xml to the caller. The engine only takes i/o as an idmef xml message. So the script needs to return a similarly formatted xml message. I have a class which does my formatting for me and it would like the script writers to use it. So quest...

Referencing system.management.automation.dll in Visual Studio

I am beginning to look into the PowerShell model and snap-in development. The first thing I notice is to reference System.management.automation.dll. However in Visual Studio, the .NET tab does not that assembly, and neither am I able to browse to C:\windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.M...

In a Console App, is there a way to detect when StandardInput is available?

I wanna build a console app that may stop and prompt for some input, under some conditions. But I want to prompt only if input will be available. Is there a way to know if Stdin is connected to anything? I think powershell does this, and I'd like to do something similar. Powershell detects when it is run interactively, and prompts...

Powershell in SQLCLR?

In the past I've been able to embed a sripting languate (like JScript) inside the SQLCLR, so scripts can be passed as parameters of functions, to perform certain calculations. Here is a simplistic example (the function ssScriptExecute returns a concatenation of all the print's in the script): select dbo.ssScriptExecute( 'print("Calculat...

Problems connecting to an Access MDB file through PowerShell

Hello, I am attempting to connect to an Access 2000 database file (*.mdb), but I am having just a tad few issues. Here is the screenplay thus far, 1) Googled how to connect to a database using powershell which resulted in the following as a source code baseline. $adOpenStatic = 3 $adLockOptimistic = 3 $objConnection = New-Object -co...

How do I determine if a PowerShell Cmdlet parameter value was specified?

In PowerShell 1.0, if I have a cmdlet parameter of an enum type, what is the recommended method for testing whether the user specified that parameter on the cmdlet command line? For example: MyEnum : int { No = 0, Yes = 1, MaybeSo = 2 } class DoSomethingCommand : PSCmdlet ... private MyEnum isEnabled; [Parameter(Mandatory = false)] p...