It will change creation time of fileName.txt
|
1 |
Get-ChildItem "fileName.txt" | Foreach-Object { $_.CreationTime = '1/1/2020 12:34'} |
It will change values $TimeType of all files in $Folder
|
1 2 3 4 5 6 7 8 9 |
$Folder = Get-ChildItem "C:\temp\test\*" $FileTime = "3/10/1982 06:30" $TimeType = ("CreationTime", "LastWriteTime", "LastAccessTime") foreach ($File in $Folder) { foreach ($Time in $TimeType) { Get-ChildItem "$File" | Foreach-Object {$_."$Time" = "$FileTime"} } } |
It will change values $TimeSettings of all files in $Folder using Hash Table
|
1 2 3 4 5 6 7 8 9 10 |
$Folder = Get-ChildItem "C:\temp\test\*" $TimeSettings = @{'CreationTime' = '3/10/1975 06:30'; 'LastWriteTime' = '3/10/1982 06:30'; 'LastAccessTime' = '5/21/2012 13:30'} foreach ($File in $Folder) { $TimeSettings.GetEnumerator() | Foreach-Object { $FileProperty = $_.Key $DateValue = $_.Value Get-ChildItem "$File" | Foreach-Object {$_."$FileProperty" = "$DateValue"} } } |
This function retrieves the total size (in GB) of mailbox databases in Exchange Organization. There is an optional parameter to filter databases by part of name. When you specify a value for the Name attribute and no databases could be found, it retrieves 0.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Function Get-MailboxDatabaseTotalSize { param ([Parameter(Mandatory=$false, ValueFromPipeline=$false)][string]$DBPartName) $Databases = Get-MailboxDatabase -Status | Where-Object {$_.Name -ilike '*'+$DBPartName+'*'} foreach($Database in $Databases) { $RawDBSize = $Database.DatabaseSize $CounterDBTotalSize = $RawDBSize + $CounterDBTotalSize } try { $CounterDBTotalSize = "{0:n2}" -f ($CounterDBTotalSize.ToBytes() / 1GB) } catch { Write-Host "0" } Return $CounterDBTotalSize } |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# Mailbox $Mailbox = "Mail@domain.com" # Exchange server contains tracking logs - by default CAS $Serv = "exch01.domain.com" $Now = Get-Date $DayBack = (7,6,5,4,3,2,1) Write-Host $Mailbox" report" Write-Host "====================" foreach ($DayIndex in $DayBack) { $CT = $Now.AddDays(-$DayIndex) $CTDayOfWeek = (Get-Date($CT)).DayOfWeek $CTToDisplay = Get-Date($CT) -Format dd.MM.yyyy $CT = Get-Date($CT) -Format MM/dd/yyyy $CTStart = $CT+" 0:00:00AM" $CTEnd = $CT+" 23:59:59PM" $MailCount = (Get-MessageTrackingLog -Recipients $Mailbox -server $Serv -start $CTStart -end $CTEnd -ResultSize 99999 | Where-Object {$_.Source -ilike "*STORE*" -and $_.EventID -ilike "*DELIVER*" -and $_.Sender -inotlike "*MicrosoftExchange*"} | Select-Object -Unique InternalMessageId).count Write-Host $CTDayOfWeek $CTToDisplay": "$MailCount } |