最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

Powershell批处理模板

来源:动视网 责编:小采 时间:2020-11-09 14:09:10
文档

Powershell批处理模板

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
推荐度:
导读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.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


文档

Powershell批处理模板

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
推荐度:
标签: 模板 bat c
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top