小编Dis*_*ame的帖子

将IIS日志移动到AWS s3存储桶

我要求将7天之前的IIS日志上传到AWS S3 Bukcet.通过使用以下代码,我可以访问存储桶下的AWS文件夹

Import-Module "C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1"
$AKey = ""
$SKey = ""
$source = "C:\inetpub\logs\LogFiles\*"
$outputpath = "C:\scripts\Logs\logs3.txt"
Set-AWSCredentials -AccessKey $AKey -SecretKey $SKey

function Get-Subdirectories {
    param  (
        [string] $BucketName,
        [string] $KeyPrefix,
        [bool] $Recurse
    )

    @(Get-S3Object -BucketName $BucketName -KeyPrefix $KeyPrefix -Delimiter '/') | Out-Null

    if ($AWSHistory.LastCommand.Responses.Last.CommonPrefixes.Count -eq 0) {
        return
    }

    $AWSHistory.LastCommand.Responses.Last.CommonPrefixes

    if ($Recurse) {
        $AWSHistory.LastCommand.Responses.Last.CommonPrefixes | ForEach-Object { Get-Subdirectories -BucketName $BucketName -KeyPrefix $_ -Recurse $Recurse }
    }
}

function Get-S3Directories {
    param  (
        [string] $BucketName,
        [bool] $Recurse …
Run Code Online (Sandbox Code Playgroud)

powershell amazon-s3 amazon-web-services

8
推荐指数
1
解决办法
426
查看次数

第1、2、2、4格式的Powershell获取日期

我正在尝试date在PowerShell中将a DayOfWeek Month Day(st|nd|rd|th) year格式化为格式。

(Get-Date).AddDays(+1).ToString('D')
Run Code Online (Sandbox Code Playgroud)

输出为“ 2016年7月5日,星期二 ”,但需要使用以下格式:2016年7月5日,星期二

if date(Get-Date) % 100 IN (11, 12, 13) THEN 'th'
    if (Get-Date) % 10 = 1 THEN 'st'
    if (Get-Date) % 10 = 2 THEN 'nd'
    if (Get-Date) % 10 = 3 THEN 'rd'
Run Code Online (Sandbox Code Playgroud)

powershell

3
推荐指数
1
解决办法
982
查看次数