powershell写mysql_Powershell批处理模板

common.ps1 cls; #Global is public#Script is internal#Script is Script#Local is current stack level#Numbered scopes are from 0..N where each step is up to stack level (and 0 is Local)$Script:PSScriptRoot =Split-Path -Parent $MyInvocation.My

common.ps1

cls;

#Global is public

#Script is internal

#Script is Script

#Local is current stack level

#Numbered scopes are from 0..N where each step is up to stack level (and 0 is Local)

$Script:PSScriptRoot =Split-Path -Parent $MyInvocation.MyCommand.Definition

$Script:strDate = Get-Date -Format "yyyyMMdd"

#logging path and method

$Script:logfile = "$PSScriptRoot\log$($strDate).txt"

$Script:log = {$input|Tee-Object -FilePath $logfile -Append}

#commen

$Script:rem = {$Script:i = '';1..75|%{$i += '-'};$i }

#start

&$rem|&$log

try{

#your ps code

$psversiontable|&$log

$Script:pss = ps

$Script:i = 0

foreach ($ps in $pss)

{

Write-Progress -Activity "on processing..." -status "$ps...$($i.tostring() + '/' + $pss.count.tostring())" -percentcomplete ($i++/($pss.count)*100)

sleep 1

}

}

catch {

"At $(Get-Date -Format “yy-MM-dd HH:mm:ss”) error occured:$_.Exception"|&$log

}finally{

&$rem|&$log

"Finish deploying at $(Get-Date -Format “yy-MM-dd HH:mm:ss”)"|&$log

}

notepad "$logfile"

start.bat

@echo off

@cd %cd%

@set vers=2.0

:Entrance

cls

goto Start

:Start

title APOMS SQL Deployment Guide

echo Please select an option from the list with the corresponding key

echo ----------------------------------------------------------------

echo [1] Test

echo [2] Exit

ech【本文来自鸿网互联 (http://www.68idc.cn)】o ----------------------------------------------------------------

CHOICE /c 12 /M "Choice->"

if errorlevel 2 GOTO exit

if errorlevel 1 GOTO GenA

rem Generate Append

:GenA

cls

echo starting powershell,Generate Append

powershell -file %cd%\common.ps1 -nologo -version %vers% -Mta

echo finished

rem timeout 2

pause

goto :Entrance

rem Generate Merge

:GenM

cls

echo starting powershell,Generate Merge

rem powershell -file %cd%\module\GenerateMerge.ps1 -nologo -version %vers% -Mta

echo finished

pause

goto :Entrance

rem Depoly

:Depo

cls

echo Caching sqlcmd files to local.

powershell -file %cd%\Mail\Send-AvEmail.ps1 -nologo -version %vers% -Mta

echo finished

pause

goto :Entrance

rem clear

:clea

cls

echo clearing CachedSQLS

rem powershell -file %cd%\module\ClearCachedSQLS.ps1 -nologo -version %vers% -Mta

echo finished

pause

goto :Entrance

rem Set-ExecutionPolicy -ExecutionPolicy remotesigned

:setP

cls

echo Set-ExecutionPolicy -ExecutionPolicy remotesigned

powershell -file %cd%\module\Set-ExecutionPolicy.ps1 -nologo -version %vers% -Mta

echo finished

pause

goto :Entrance

rem Config

:Conf

cls

echo configuring powershell inittial parameters:

echo edit and save to contiue.

rem echo editing %cd%\module\config

rem notepad %cd%\module\config

echo editing %cd%\module\config_sys

notepad "%cd%\module\config_sys"

echo testing config_sys

powershell -file %cd%\module\TestConfig.ps1 -nologo -version %vers% -Mta

pause

goto :Entrance

rem Help

:Help

cls

@type %cd%\module\help.txt

pause

goto :Entrance

rem SqlCMD

:SqlC

cls

powershell -file %cd%\module\GenerateSqlcmdFiles-force.ps1 -nologo -version %vers% -Mta

pause

goto :Entrance

rem default

:N

cls

echo Invalid Selection! Try again

@type %cd%\module\help.txt

pause

goto :Entrance

rem exit

:Exit

exit

f68f2add0b68e4f9810432fce46917b7.png

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值