English 中文(简体)
如何建立动态权力?
原标题:How to create dynamic powershell query?

我有一个权力问题,以获得我数据库的备份。 但是,需要以不同的名称(如DATABASEBACKUP)支持数据。 CURRENTDATE. 如何做到这一点?

./RedGate.SQLAzureBackupCommandLine.exe /as: AzureServerNAME/ad: AzureDatabaseName    /au:AzureUserName /ap:AzurePassword /cc /s /ls:. /ld:LOCALDATABASENAME_CURRENTDATE /dl /v /ba
最佳回答

第一,建立载有目前日期的说明:

$backupName = $("Backup-{0}" -f [DateTime]::Now.ToString("yyyy-MM-dd"))

之后称为“红色”并使用标号作为参数:

./RedGate.SQLAzureBackupCommandLine.exe /as: AzureServerNAME /ad: AzureDatabaseName /au:AzureUserName /ap:AzurePassword /cc /s /ls:. /ld:$backupName /dl /v /ba

Ed: 制版/标书,附括号和分号,固定版。

问题回答

为了在当日建造一个护堤,你只能做:

"DATABASEBACKUP_{0:MM-dd-yyyy}" -f [DateTime]::Now

It will give something like DATABASEBACKUP_01-12-2012. You can use that as arguments as needed

采用另一种解决办法......

“DATABASEBACKUP_$(Get-Date -Format MM-dd-yyyyyy)”





相关问题
Mutually exclusive powershell parameters

SCENARIO I m writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5 the cmdlet requires 3 arguments. my intended grammar of the cmdlet is something like this: cmdletname [foo|...

Run a program from PowerShell with timeout

I ll write a script that runs a program and wait for it finished. But if the program is not finished within a specified time I want that the program is killed.

How to transpose data in powershell

I have a file that looks like this: a,1 b,2 c,3 a,4 b,5 c,6 (...repeat 1,000s of lines) How can I transpose it into this? a,b,c 1,2,3 4,5,6 Thanks

Powershell v2 remoting and delegation

I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

热门标签