Home Database Mysql Tutorial Powershell批处理模板

Powershell批处理模板

Jun 07, 2016 pm 04:12 PM
c powershell Batch processing template

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"
Copy after login


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
Copy after login


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are constants in C language? Can you give an example? What are constants in C language? Can you give an example? Aug 28, 2023 pm 10:45 PM

A constant is also called a variable and once defined, its value does not change during the execution of the program. Therefore, we can declare a variable as a constant referencing a fixed value. It is also called text. Constants must be defined using the Const keyword. Syntax The syntax of constants used in C programming language is as follows - consttypeVariableName; (or) consttype*VariableName; Different types of constants The different types of constants used in C programming language are as follows: Integer constants - For example: 1,0,34, 4567 Floating point constants - Example: 0.0, 156.89, 23.456 Octal and Hexadecimal constants - Example: Hex: 0x2a, 0xaa.. Octal

VSCode and VS C++ IntelliSense not working or picking up libraries VSCode and VS C++ IntelliSense not working or picking up libraries Feb 29, 2024 pm 01:28 PM

VS Code and Visual Studio C++ IntelliSense may not be able to pick up libraries, especially when working on large projects. When we hover over #Include<wx/wx.h>, we see the error message "CannotOpen source file 'string.h'" (depends on "wx/wx.h") and sometimes, autocomplete Function is unresponsive. In this article we will see what you can do if VSCode and VSC++ IntelliSense are not working or extracting libraries. Why doesn't my Intellisense work in C++? When working with large files, IntelliSense sometimes

Fix Xbox error code 8C230002 Fix Xbox error code 8C230002 Feb 27, 2024 pm 03:55 PM

Are you unable to purchase or watch content on your Xbox due to error code 8C230002? Some users keep getting this error when trying to purchase or watch content on their console. Sorry, there's a problem with the Xbox service. Try again later. For help with this issue, visit www.xbox.com/errorhelp. Status Code: 8C230002 This error code is usually caused by temporary server or network problems. However, there may be other reasons, such as your account's privacy settings or parental controls, that may prevent you from purchasing or viewing specific content. Fix Xbox Error Code 8C230002 If you receive error code 8C when trying to watch or purchase content on your Xbox console

Recursive program to find minimum and maximum elements of array in C++ Recursive program to find minimum and maximum elements of array in C++ Aug 31, 2023 pm 07:37 PM

We take the integer array Arr[] as input. The goal is to find the largest and smallest elements in an array using a recursive method. Since we are using recursion, we will iterate through the entire array until we reach length = 1 and then return A[0], which forms the base case. Otherwise, the current element is compared to the current minimum or maximum value and its value is updated recursively for subsequent elements. Let’s look at various input and output scenarios for this −Input −Arr={12,67,99,76,32}; Output −Maximum value in the array: 99 Explanation &mi

PHP email templates: customize and personalize your email content. PHP email templates: customize and personalize your email content. Sep 19, 2023 pm 01:21 PM

PHP email templates: Customize and personalize your email content With the popularity and widespread use of email, traditional email templates can no longer meet people's needs for personalized and customized email content. Now we can create customized and personalized email templates by using PHP programming language. This article will show you how to use PHP to achieve this goal, and provide some specific code examples. 1. Create an email template First, we need to create a basic email template. This template can be an HTM

C++ program to print spiral pattern of numbers C++ program to print spiral pattern of numbers Sep 05, 2023 pm 06:25 PM

Displaying numbers in different formats is one of the basic coding problems of learning. Different coding concepts like conditional statements and loop statements. There are different programs in which we use special characters like asterisks to print triangles or squares. In this article, we will print numbers in spiral form, just like squares in C++. We take the number of rows n as input and start from the top left corner and move to the right, then down, then left, then up, then right again, and so on and so on. Spiral pattern with numbers 123456724252627282982340414243309223948494431102138474645321120373635343312191817161514

How to add PPT mask How to add PPT mask Mar 20, 2024 pm 12:28 PM

Regarding PPT masking, many people must be unfamiliar with it. Most people do not understand it thoroughly when making PPT, but just make it up to make what they like. Therefore, many people do not know what PPT masking means, nor do they understand it. I know what this mask does, and I don’t even know that it can make the picture less monotonous. Friends who want to learn, come and learn, and add some PPT masks to your PPT pictures. Make it less monotonous. So, how to add a PPT mask? Please read below. 1. First we open PPT, select a blank picture, then right-click [Set Background Format] and select a solid color. 2. Click [Insert], word art, enter the word 3. Click [Insert], click [Shape]

The function of void keyword in C language The function of void keyword in C language Feb 19, 2024 pm 11:33 PM

void in C is a special keyword used to represent an empty type, which means data without a specific type. In C language, void is usually used in the following three aspects. The function return type is void. In C language, functions can have different return types, such as int, float, char, etc. However, if the function does not return any value, the return type can be set to void. This means that after the function is executed, it does not return a specific value. For example: voidhelloWorld()

See all articles