|
|
Browse by Tags
All Tags » Hey! » PowerShell
Showing page 1 of 2 (12 total posts)
-
A Translation of the Scripting Guys post : How Can I Copy Files Based on Multiple Criteria? VbScript example,
As mostly in this series I point to the original Article for more information.
dir c:\Scripts |? {$_ -match ''^FS|^CG|^GPS.'' -and $_.CreationTime -gt (get-date).AddDays(-1)} | copy -dest C:\Test
And on the Scripting Guy's remark in ...
-
Another Hit-in-one(liner) translation from a ca 30 lines VbScript example :
How Can I Delete All the Files in a Folder Except for the Most-Recently Created File?
del *.* -Exclude (dir | sort creationtime -desc)[0] -whatif
Remove the -WhatIf to actualy delete the files.
Enjoy,
Greetings /\/\o\/\/
-
Today's Hey Scripting Guy ! column , How Can I Retrieve All the Values in a Registry Key? , Shows a 38 line VbScript to get the Values in a registry key.
In a PowerShell console it just takes this simple line to do the same :
get-ItemProperty 'hkcu:\Software\Microsoft\Internet Explorer\Main'
The big difference in this case is ...
-
How Can I Check to See if Two Lines of Text are in a File and, If They Are Not, Append Those Lines to the File?
Translation to PowerShell of a Hey, Scripting Guy! column that shows you how to check a text file for specific lines containing double quote marks and add those lines if it they don't exist.
$l = ...
-
How Can I Separate The Month From the Year in a Date String Like 122007?
[datetime]::ParseExact(122007,'Myyyy',$null) | ft Month,Year
You can see you can use ParseExact to convert a custom format to d dateTime OBject from there it is simple of course
PS> [datetime]::ParseExact(122007,'Myyyy',$null)
zaterdag 1 december 2007 ...
-
From the Scripting Son article : How Can I Determine the Currency Symbol in Use on a Computer?
3 ways to do the same in PowerShell :
(gp 'hkcu:\Control panel\International').sCurrency
(get-culture).NumberFormat.CurrencySymbol
'{0:c}' -f 1
And yes we can do it remote also :
$Computer = ...
-
No solutions to post today , so time for a small Hey scripting guy ! translation : How Can I Replace Incorrect Dates in My File Names?
dir *.jpg | ren -new {$_.name -replace ''(\d{1,2})-(\d{1,2})-07'','$1-$2-08' }
To keep the example clear I used exactly the same regex as the scripting guy did.
this is a typical example how powerfull ...
-
A little one before the, 2008 Winter Scripting Games
The PowerShell version of the Hey Scripting guy VBScript version : How Can I Remove Extraneous Spaces From Fields in a Text File?
(gc c:\scripts\test.txt) -replace ' {2,}',''PoSH> gc c:\scripts\test.txt ...
-
In the Hey Scripting guy ! article : How Can I Create an HTA For Displaying Log Files? ,
I made this example in PowerShell Using Windows Forms using the PSEventing CodePlex project PowerShell Eventing Snapin from Oisin the handle the ItemActivated event from the ListView.
I used a SplitControl Panel to make the Listview sizeable and the Form ...
-
In TechNet Magazine you can find the Scripting Guy article The Games Are Afoot! Oh, and Some XML, Too
I translated the scripts given for this article into PowerShell
# Create
$xml = New-Object xml
$root = $xml.CreateElement("ITChecklist")
[void]$xml.AppendChild($root)
$Record = ...
1
|
|
|