Powershell: put yesterday's date in a file name

I'm trying to do the following three steps with a powershell script: drop the file extension (.part) of all files ending with the pattern "*flv.part". So files ending with ".flv.part" would now end simply with ".flv". Add yes

Error during DateTime scan

I am trying to parse "time" strings for comparison purposes $Test2 =[datetime]::Parse("24/09/2015 05:41:27",[Globalization.cultureinfo]::GetCultureInfo("en-US")) $Test2 $Test =[datetime]::Parse("23/09/2015 05:41:27"

Powershell V2 - removes the last x characters from a string

I have a file containing a few thousand lines of text. I need to extract some data from it, but the data I need is always 57 characters from the left, and 37 characters from the end. The bit I need (in the middle) is of varying length. e.g. 20141126_

Insert a background color in a row

I have a file input.txt having below content: ENVIRONMENT SERVER APPLICATION STATUS Test Windows abcd Success Dev Linux wxyz Failed Prod Windows pqrs Success Test Ubuntu efgh NoValue And using below script I use to convert this file's content into ta

Enabling desktop experience from C # on Windows 2008/2012

I am currently using command: servermanagercmd -install Desktop-Experience From what I read, I understood that this is no longer supported in Windows 2012. I understood that can be done from PowerShell cmdlet somehow but can't find an example for a n

Export function

I am trying to create a function in which a user has to give a filename that can not containt an empty string. Besides that, the string can not contain a dot. When I run this function, I keep looping when I enter "test" for example. Any idea as

Batch script calling a powershell function

Is there a way for a batch file to call a powershell function? I've tried powershell ". .\tes.ps1; Test-Me -Param1 'Hello world' -Param2 12345" And it works, the function gets called, but so does everything else in the powershell script.It looks

relative path in Import-Module

I have directory structure that looks like this: C:\TFS\MasterScript\Script1.ps1 C:\TFS\ChildScript\Script2.ps1 What i want to do is specify the relative path in Script2.ps1 to look for Script1.ps1 in the directory hirearchy. This is what i tried in

Place a Yes or No in an Excel spreadsheet based on a value

Thanks in Advance! Here is the code:I want to gather the value of the below variable... $Sheet3.Cells.Item($intRowDisk, 4) = $objItem.Size/1024/1024/1024 - $objItem.FreeSpace/1024/1024/1024 Then I want to compare that value and if it is larger than 1

Retrieving an RDN from an Active Directory User Object

Is it possible to retrieve the RDN of a user object in Active Directory with the attribute intact. I've done a lot of reading on this and found that an AD user object stores the RDN in an property called "name". Supposedly the value of the name

PowerShell 2.0 Can not Get Internet Explorer Logs

When I try to run cmd get-eventlog -list on win2003 std in powershell V2.0. It gives me the following output Max(K) Retain OverflowAction Entries Log ------ ------ -------------- ------- --- 16,384 0 OverwriteAsNeeded 117 Application 512 7 OverwriteO

SendMessage causes the script to crash

I am having an issue where the SendMessage() function is causing a script to hang and thus never exiting though it is running the SendMessage like it should (Its task completes). Is there anyway to get around this because I am having a heck of a time

Powershell - the digital format indicates an incorrect result

in powershell v2, I need to divide 22 by 8 and then strip all the decimal places after the decimal point (which is on my system a comma). No rounding. As you see. 22/8 equals 2,75 PS C:\Documents and Settings\Administrator> $(22/8) 2,75 Expected resu

PowerShell: Difference between table notation?

Is there a difference between these two array creation statements? So, is '@' sign optional when creating arrays? $a = "This", "Is", "a", "cat" $a.GetType() $a | gm $a = @("This", "Is", "a&q

Problem with the WMI filter

I've got a notepad.exe started in my session : gwmi -Query "Select CommandLine from Win32_Process where CommandLine='C:\Windows\system32\notepad.exe'" gives Get-WmiObject : Demande non valide Au niveau de ligne : 1 Caractère : 5 + gwmi <<&

PowerShell - Download files with WebDAV

I want to use PowerShell with WebDAV (https) to download multiple files from a folder. The name from the download files is unknown. So my plan is to download all files from this folder and create a cleaning job at the server. At the moment I´m search

How can I delete repetitive text from a file?

I have a file which has a list of SQL Server databases. I want to remove the 4 system databases, [master,model,msdb,tempdb] from the file. How can I do that? Server1 [DB1] [DB2] [DB3] [master] [model] [msdb] [tempdb] Server2 [DB1] [DB2] [DB3] [master

How to get all the groups of which a user is a member?

PowerShell's Get-ADGroupMember cmdlet returns members of a specific group. Is there a cmdlet or property to get all the groups that a particular user is a member of? I fixed my mistake: Get-Member should be Get-ADGroupMember.Get-ADPrincipalGroupMembe

Founder of Powershell

Can anyone give me an example of how to use BackgroundWorker in Powershell? I want to write something so when a new tab is selected in my Powershell GUI app, it will switch to the tab with a "please wait" message displayed, then run some checks

Speed ​​up PowerShell scripts in V2?

I'm running a number of scripts using PowerShell V2, and I have noticed a long pause when the console window first loads. What can I do to improve the performance of my scripts? Thanks, MagicAndiOther than minimize what you put in your various profil

PowerShell, Web Queries, and Proxies

When making a simple web request is there a way to tell the PowerShell environment to just use your Internet Explorer's proxy settings? My proxy settings are controlled by a network policy(or script) and I don't want to have to modify ps scripts late