[Solved] Using Powershell to copy file from network drive to local drive

Your example is almost complete on its own. You can further your pipeline: $UNC = ‘\\share’ $Path=”C:\Temp” Get-ChildItem -Path $UNC | Where-Object { $_.LastWriteTime -lt (Get-Date) } | ForEach-Object { Copy-Item -Path $_.FullName -Destination $Path } Although, an improvement: $Path=”C:\Temp” $UNC = Get-ChildItem -Path ‘\\share’ -File $Local = Get-ChildItem -Path $Path -File ForEach ($File in … Read more

[Solved] Parse string in Powershell and create a table

I have to admit this is a bit excesive use of .replace() but there isn’t much to work with: $mystring= ” S: Title = test S: Title = test2 S: Title = test3 S: Title = test4 TE: 2019-01-19T00:00:00Z TE: 2019-01-20T00:00:00Z TE: 2019-01-22T00:00:00Z TE: 2019-01-23T00:00:00Z ” $MyString.trim().replace(” S: Title = “,”,”).replace(“T00:00:00Z TE: “,”,”).replace(“TE: “,””).replace(“S: Title … Read more

[Solved] Download and run files using PowerShell [closed]

To answer part of your question: Using Invoke-WebRequest you can feed it a url and use the parameter -OutFile to send it somewhere locally on your machine, example: $url = example.com/somefile.jpg Invoke-WebRequest $url -OutFile C:\output\somefile.jpg This will download the somefile.jpg from example.com and save it in C:\output\ on your machine https://msdn.microsoft.com/powershell/reference/5.1/Microsoft.PowerShell.Utility/Invoke-WebRequest 7 solved Download and … Read more

[Solved] output file properties like filename, etc in powershell into a csv

Get-ChildItem C:\Windows\System32\ | Select-Object Name,CreationTime,@{n=’MD5′;ex={(Get-FileHash $_.fullname).hash}} Use -Recurse parameter if you want to get files from sub directories also: Get-ChildItem C:\Windows\System32\ -Recurse Use -File parameter if you want to get only files and not folders: Get-ChildItem C:\Windows\System32\ -Recurse -File Type the following command to get the list of all available properties: Get-ChildItem | Get-Member 9 … Read more

[Solved] powershell script to attach the html file in body of email

i used 2 scripts but i suppose you could use one Make the html file $FILENAME = HTMLfilename $head = @’ <title>page title</title> <style> maybe some css</style> ‘@ $title01 = @’ <h1>some text above html file</h1> ‘@ $body = @” <a href=”https://stackoverflow.com/questions/36691354/$FILENAME.html”>filename</a> ‘@ $x = some code $x | Select-object Name | ConvertTo-HTML -head $head … Read more

[Solved] multiple exclude rules in powershell

I post this as an answer as I don’t have the characters to do it as comment. Let me see if I understand this. $Files = Get-ChildItem -File C:\Setup | select Name, LastWriteTime You then have an export of the files like: Name LastWriteTime —- ————- SS_MM_Master_Finland_2017.txt 6/27/2018 4:30:09 PM SS_MM_Master_Finland_2018.txt 6/27/2018 4:30:09 PM SS_MM_Master_Germany_2017.txt … Read more

[Solved] Powershell Script to parse selected information from txt file and output to csv

As suggested choose a regular expression that matches your requrements (see regex101.com) iterate the matches and compare the ,matched text generate a [PSCustomObject] for your csv ## Q:\Test\2018\10\17\SO_52857274.ps1 $RE = [RegEx]’^.*?\.(\d{4}):[^”]+”\s*(included with your TV purchase|.*)”$’ $CSV = Select-String ‘.\my.txt’ -Pattern $RE | ForEach-Object { IF ($_.Matches.Groups[2].Value -eq ‘included with your TV purchase’){ $Install = $True … Read more

[Solved] how to create ps1 file which takes input as json and based on parameters exceute batch file? [closed]

This is a Batch-file solution (posted here because this question have the batch-file tag) that IMO is simpler than any ps1 solution, but I am sure it run faster than the ps1 solution. @echo off setlocal EnableDelayedExpansion set “Version=” for /F “tokens=1,2 delims=:, ” %%a in (‘findstr “:” input.txt’) do ( set “%%a=%%~b” if defined … Read more

[Solved] Powershell – what’s this line saying?

Lets break apart this command $currentuserid = Get-WmiObject -Class win32_computersystem -ComputerName $workstation | Select-Object -ExpandProperty Username In powershell $ is the identifier for a variable. This means $currentuserid will equal the output of the last command in the pipe, In this case Select-Object. Also in powershell -whatever after a command is a parameter. The | … Read more

[Solved] Get the users associated with Database

function SQL-Get-Logins { <# .SYNOPSIS Returns a list of SQL Server logins defined on the specified server/instance. .DESCRIPTION This function returns a complete list of all logins defined for the specified server/instance, including the login type, the default database, and the server role. .PARAMETER server The computer hosting SQL Server. .PARAMETER instance The instance to … Read more

[Solved] pass value to custom field in azure board task, user story etc

There is no custom endpoint for populating fields, they are part of the workitem endpoint on _apis/wit/workitems and can be passad along in the POST request when creating a workitem or updated through PATCH request Update the value of a field on an existing item If you want to update a field on an existing … Read more