Tag Info

Hot answers tagged

4

Unfortunately - this is like asking which car is best suited to people who drive... there is and never will be a definitive answer.. That said, there are some good generalisations you can make: For administering pretty much anything Windows 7/2008R2 and newer - PowerShell is a very good choice. The reason for this is that it leverages a lot of the power ...


3

Get the file object then set the property: $file = Get-Item C:\Path\TO\File.txt $file.LastWriteTime = (Get-Date) or for a folder: $folder = Get-Item C:\folder1 $folder.LastWriteTime = (Get-Date)


3

This is a well-known limitation in Powershell, unfortunatelly. This question has already been answered in StackExchange, the acepted answer was to use cmd and dir instead, to gather the folders list. This answer also provided the following reference link : http://asysadmin.tumblr.com/post/17654309496/powershell-path-length-limitation wich basically ...


2

Even if your second script will work, this one is simpler to understand, and written in 'better PowerShell' : $currentfolder = Get-Location Get-ChildItem - path $currentfolder -File -Include folder.jpg,albumart*.jpg,desktop.ini -Recurse | Remove-Item -Force -Verbose Hope this helps !


1

Did you try using a wildcard? Remove-Item "C:\Jenkins\workspace\Long Path with *" That will delete all file in that folder that start with "Long Path with ".


1

I asked Don Jones the powershell guru on another forum and he gave me the info I needed. He explained it to me by saying this: If I'm understanding the question, then you basically have to factor out all the possible combinations. Remember that a param can belong to 1+ param sets. So, you might have a set with Computername and OULevel, Computername and ...


1

You can use the static Round method from the [math] class: [Math]::Round((Get-WmiObject -Class win32_computersystem -ComputerName localhost).TotalPhysicalMemory/1Gb) Using this command on your example will return the expected number 16.


1

The problem was with the path to the pdf file. I was specifying that the script look in the current folder by passing in "." so the output name was: .\Output\Example.pdf when I added the line: $fullFolder = Resolve-Path -Path $folder and then used $fullFolder instead of $folder the SaveAs worked as the output filename became: D:\Documents\User ...


1

this is what I use in one of my scripts. Try taking the variables out of the quotes. Send-MailMessage -From $From -To $To -Subject $Subject -SmtpServer $SMTPServer -BodyAsHtml Also, what version of powershell are you running as I think Send-MailMessage is v2 and above. $PSVersionTable.PSVersion



Only top voted, non community-wiki answers of a minimum length are eligible