powershell

Can I "draw"/create an image with a given text with powershell?

Hi, I just wondered if it would be possible to create a small, simple jpg, png, gif with a given Text in powershell: e.g: a small square, 250px × 61px, yellow background and black text on it: "Test" Can I do this with "System.Drawing.Image"? Thanks ...

Powershell, how to update several dns records

I have the following script, but am getting an error - Script - $CNAMES = Get-Content "C:\Temp\alias.txt" $Query = "Select * from MicrosoftDNS_CNAMEType" $Record = Get-WmiObject -Namespace "root\microsoftdns" -Query $Query -ComputerName 10.10.10.1 | Where-Object{$_.Ownername -match $CNAME} Foreach($CNAME in $CNAMES) { $Record.RecordD...

Run a powershell script in the background once per minute

I want a powershell script to be run once per minute in the background. No window may appear. How do I do it? ...

.NET class documentation from within PowerShell?

Is there a convenient method to access .NET class documentation (i.e. the MSDN documentation) from within PowerShel similar to "man 3" in UNIX shells? ...

Remove Top Line of Text File with Powershell

I'll be honest I feel dumb about this one. I am trying to just remove the first line of about 5000 text files before importing them. I am still very new to powershell so not sure what to search for or how to approach this. My current concept using pseudo-code set-content file (get-content unless line contains amount) However, I can't ...

How to determinate a CNAME on Windows? via Poweshell or others

I want to know if exists a scriplet to know the local SERVER CNAME, or via CMD, regedit, etc ...

Get all webpart properties via Powershell for each page in SharePoint site

Hi, I have a site in Sharepoint 2007 (not mine personally) with some subsites. For each subsite, and each of its pages, how can I get all the webpart's properties? This is using Powershell (Server does not have Visual Studio, another matter). Thanks ...

How to hash only image data in a jpg file with dotnet?

I have a ~20000 jpg images, some of which are duplicates. Unfortunately, some files have been been tagged with EXIF metadata, so a simple file hash cannot identify the duplicated one. I am attempting to create a Powershell script to process these, but can find no way to extract only the bitmap data. The system.drawing.bitmap can only r...

Invoke an exe from PowerShell and get feedback on succes or failure

How can I run an executable in PowerShell and through an if statement decide whether it succeeded or failed? More specifically I'm trying to get devenv.exe to build a solution from a PowerShell script and I need to know whether it succeeded or failed. By failed, I mean that the build has failed and I'm assuming devenv is sending somethi...

Detect If IPv6 is Enabled on Windows Machines

Hi Folks, I am writing a powershell script that will act as a build compliance test for our servers. One of the things I need to do is detect if IPv6 networking has been disabled. WMI indicates that this information can be found in the IPAddress Property of Win32_NetworkAdapterConfiguration but can be both IPv6 or IPv4. This does not g...

How to get current username in Windows Powershell?

How to get the current username in Windows Powershell? ...

Good in-memory database for .net/PowerShell?

If I have a script that handles state information that's a bit more complex that can be stored in variables, what's the best option for a small in-memory database? Sqlite is an option, though that would be an external dependency. XML might do, though it's non-relational. Is there any consensus on a tool for this job? ...

Powershell equivalent to F# Seq.forall

I've written this (which works): function ForAll { BEGIN { $allTrue = $true } PROCESS { if ($_ -lt 1) { $allTrue = $false } } END { $allTrue } } $aList = (0..4) $bList = (1..4) $aList | ForAll # returns false $bList | ForAll # returns true But what I want to do is replace the ($_ -lt...

launch powershell under .NET 4

I am updating a PowerShell script that manages some .NET assemblies. The script was written for assemblies built against .NET 2 (the same version of the framework that PowerShell runs with), but now needs to work with .NET 4 assemblies as well as .NET 2 assemblies. Since .NET 4 supports running applications built against older versions ...

Error when calling 3rd party executable from Powershell when using an IDE

I have a PowerShell script that uses du.exe (Disk Usage originally from Sysinternals) to calculate the size of directories. If I run du c:\Backup in the console, it works as expected, but the same line of code run in ISE or PowerGui gives the expected result plus the error + du <<<< c:\backup + CategoryInfo : NotSpecified:...

Write-Host adds "PS>" at the end of prompt?

If I use write-host to define my prompt, Powershell adds "PS>" automatically at the end. How can I use write-host so that it doesn't do that? function prompt { '> ' } #prompt: #> function prompt { write-host '> ' -foregroundcolor "green" } #prompt: #> #PS> ...

Weird string expansion with powershell

I'm using the string expansion feature to build filenames, and I don't quite understand what's going on. consider: $baseName = "base" [int]$count = 1 $ext = ".ext" $fileName = "$baseName$count$Ext" #filename evaluates to "base1.ext" -- expected #now the weird part -- watch for the underscore: $fileName = "$baseName_$count$Ext" #fil...

How to prevent from closing out-gridview when a script finishes

I have a script that presents results using out-gridview. Here is a simple example: "hello world" | out-gridview When I run the script using Run with PowerShell, it will open gridview and close it immediately after it is opened. (I think this is because gridview is not modal and the script finishes.) How to make the PowerShell wait u...

check string for all lowercase letters in powershell

I want to be able to test if a powershell string is all lowercase letters. I am not the worlds best regex monkey, but I have been trying along these lines: if( $mystring -match "[a-z]^[A-Z]" ) { echo "its lower!" } But of course they doesn't work, and searching the interwebs hasn't got me anywhere. Does anyone know the way to do this...

What is the powershell equivalent to this bash command?

I'm trying to create a cli command to have TFS check out all files that have a particular string in them. I primarily use cygwin but the tf command has trouble resolving the path when run within the cygwin environment. I figure powershell should be able to do the same thing, but I'm not sure what the equivalent commands to grep and xar...