$TargetFolder = 'F:\temp\test1'
$DestinationFolder = 'F:\temp\test2'
Get-ChildItem $TargetFolder -Recurse |
Where-Object { $_.Name -match '.log$' -and !$_.PsIsContainer } |
Copy-Item -Destination { mkdir $_.DirectoryName.Replace("$TargetFolder","$DestinationFolder") -Force }
Function Get-NProcesses
{
param (
[switch]$Multiple,
[switch]$LastProcess
)
$listProcesses = Get-Process| Select-Object -Unique | Select-Object -Property ProcessName, StartTime | Where-Object { $_.StartTime -ne $null }
if($Multiple)
{
foreach($process in $listProcesses.ProcessName)
{
if((Get-Process $process).Count -gt 1)
{
$process
}
}
}
if($LastProcess)
{
$listProcesses | Sort-Object -Property StartTime | Select-Object -Last 1
}
}
Import-Module /path/to/test1.psm1
Get-NProcesses -Multiple
Get-NProcesses -LastProcess
$destinationDir = "D:\"
$mainDir = "new_project"
$subDirs = @("css", "js")
$files = @("index.html", "style.css", "script.js", "script.min.js")
Foreach ($subDir in $subDirs)
{
if (!(Test-Path -Path "$destinationDir/$mainDir/$subDir"))
{
New-Item -Path "$destinationDir/$mainDir/$subDir" -ItemType Directory
}
Foreach ($file in $files)
{
if ($file -match ".$subDir")
{
if (!(Test-Path -Path "$destinationDir/$mainDir/$subDir/$file"))
{
New-Item -Path "$destinationDir/$mainDir/$subDir/$file" -ItemType File
}
}
elseif ($file -match ".html")
{
if (!(Test-Path -Path "$destinationDir/$mainDir/$file"))
{
New-Item -Path "$destinationDir/$mainDir/$file" -ItemType File
}
}
}
}