PowerShell和Bash的介绍
PowerShell是运行在windows平台的脚本,而Bash是运行在linux平台的脚本
现在bash能做的事情,PowerShell也能做,PowerShell的强大之处是它可以管理windows服务器(特别是域domain),现在的开源PowerShell 也可以管理Linux和Mac(通过PSRP)。
下载最新的PS程序
https://msdn.microsoft.com/en-us/Mt173057.aspx
安装后它会有powershell和它的开发IDE工具,ISE,非常不错!
一、进行powershell的程序

二、创建脚本,简单的Helloworld.ps1
任务的自动化是以程序文件或者可执行脚本文件为基础的,PowerShell也支持将命令列表做成脚本文件来执行。以下是Helloworld.ps1脚本文件的内容:
$a = "Hello World!"
$a
echo $a > a.txt
dir a.txt
Helloworld.ps1脚本文件的执行情况结果如下:
PS E:\>.\Helloworld.ps1 --注意在执行它时要加.\,表示当前上当下的文章,类似于centos里的文件执行方法
Hello world!Directory: E:\Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 5/30/2017 4:56 PM 16 a.txt
下面是在eShopOnContainers上的一个例子,分别用ps和bash实现了程序的部署
#!/bin/bash
declare -a projectList=(
'../src/Services/Catalog/Catalog.API'
'../src/Services/Basket/Basket.API'
'../src/Services/Ordering/Ordering.API'
'../src/Services/Identity/Identity.API'
'../src/Web/WebMVC'
'../src/Web/WebSPA'
'../src/Web/WebStatus'
) # Build SPA app
# pushd $(pwd)../src/Web/WebSPA
# npm run build:prod for project in "${projectList[@]}"
do
echo -e "\e[33mWorking on $(pwd)/$project"
echo -e "\e[33m\tRemoving old publish output"
pushd $(pwd)/$project
rm -rf obj/Docker/publish
echo -e "\e[33m\tRestoring project"
dotnet restore
echo -e "\e[33m\tBuilding and publishing projects"
dotnet publish -o obj/Docker/publish
popd
done # remove old docker images:
images=$(docker images --filter=reference="eshop/*" -q)
if [ -n "$images" ]; then
docker rm $(docker ps -a -q) -f
echo "Deleting eShop images in local Docker repo"
echo $images
docker rmi $(docker images --filter=reference="eshop/*" -q) -f
fi # No need to build the images, docker build or docker compose will
# do that using the images and containers defined in the docker-compose.yml file.
powershell代码如下
Param([string] $rootPath)
$scriptPath = Split-Path $script:MyInvocation.MyCommand.Path Write-Host "Current script directory is $scriptPath" -ForegroundColor Yellow if ([string]::IsNullOrEmpty($rootPath)) {
$rootPath = "$scriptPath\.."
}
Write-Host "Root path used is $rootPath" -ForegroundColor Yellow $projectPaths =
@{Path="$rootPath\src\Web\WebMVC";Prj="WebMVC.csproj"},
@{Path="$rootPath\src\Web\WebSPA";Prj="WebSPA.csproj"},
@{Path="$rootPath\src\Services\Identity\Identity.API";Prj="Identity.API.csproj"},
@{Path="$rootPath\src\Services\Catalog\Catalog.API";Prj="Catalog.API.csproj"},
@{Path="$rootPath\src\Services\Ordering\Ordering.API";Prj="Ordering.API.csproj"},
@{Path="$rootPath\src\Services\Basket\Basket.API";Prj="Basket.API.csproj"}
@{Path="$rootPath\src\Web\WebStatus";Prj="WebStatus.csproj"} $projectPaths | foreach {
$projectPath = $_.Path
$projectFile = $_.Prj
$outPath = $_.Path + "\obj\Docker\publish"
$projectPathAndFile = "$projectPath\$projectFile"
Write-Host "Deleting old publish files in $outPath" -ForegroundColor Yellow
remove-item -path $outPath -Force -Recurse -ErrorAction SilentlyContinue
Write-Host "Publishing $projectPathAndFile to $outPath" -ForegroundColor Yellow
dotnet restore $projectPathAndFile
dotnet build $projectPathAndFile
dotnet publish $projectPathAndFile -o $outPath
} ########################################################################################
# Delete old eShop Docker images
######################################################################################## $imagesToDelete = docker images --filter=reference="eshop/*" -q If (-Not $imagesToDelete) {Write-Host "Not deleting eShop images as there are no eShop images in the current local Docker repo."}
Else
{
# Delete all containers
Write-Host "Deleting all containers in local Docker Host"
docker rm $(docker ps -a -q) -f # Delete all eshop images
Write-Host "Deleting eShop images in local Docker repo"
Write-Host $imagesToDelete
docker rmi $(docker images --filter=reference="eshop/*" -q) -f
} # WE DON'T NEED DOCKER BUILD AS WE CAN RUN "DOCKER-COMPOSE BUILD" OR "DOCKER-COMPOSE UP" AND IT WILL BUILD ALL THE IMAGES IN THE .YML FOR US
自己感觉,这两个东西在以后的程序部署上都会发挥各自强大的力量!
PowerShell和Bash的介绍的更多相关文章
- linux下一键安装 powershell,的bash脚本
说明 目前,linux下的powershell约等于pash.希望大家专注mono,关注pash. 一键安装脚本包括for centos6,centos7,ubuntu 14.04 ubuntu 1 ...
- 干货~powershell与bash和docker在项目中怎么用
回到目录 这个标题够直接了吧,够坦诚了吧,也许你在项目里这三个东西都没有用到,但这三个东西在未来的两年里将成为最HOT的技术,它们不是什么框架,也不是什么设计模式,而是做为程序和环境快速部署而设计出来 ...
- Linux基础之bash shell介绍及基本特性
今天继续讲Linux基础知识,内容是关于bash shell的.分享以下bash shell的相关知识,例如基本特性等. 1.8)bash shell的介绍 1.8.1)什么是bash shell ...
- 1.bash总体介绍
1.总体介绍1.1 什么是Bash?Bash(Borune-Again SHell)是一个用于Linux操作系统的shell,即命令解释器Bash与sh兼容,并从ksh和csh引进了一些有用的功能,在 ...
- Bash简单介绍
Bash不不过一个命令解析程序. 它本身拥有一种程序设计语言,使用这样的语言,能够编写shell脚本来完毕各种各样的工作.而这些工作是使用现成的命令所无法完毕的.Bash脚本能够使用if-then-e ...
- PowerShell~执行策略的介绍
首先看一下无法加载ps1脚本的解决方法 事实上也是由于策略导致的 解决方法主是开启对应的策略 set-ExecutionPolicy RemoteSigned 执行策略更改 执行策略可以防止您执行不 ...
- Typora + Powershell/bash + Git搭建自己的笔记
网上都说什么onenote,evernote,ant等笔记.个人感觉这些都不算太好,还是自己用简易东西搭建一个笔记. 个人推荐使用typora写笔记. 上面既有文件目录,还能通过模糊搜索. 然后需要p ...
- GITHUB中GIT BASH基础命令行
PS:转自https://www.cnblogs.com/WangXinPeng/p/8016293.html 1.常用命令行工具: ①cmd ②powershell ③git ba ...
- Cmder介绍和配置
一.命令行神器cmder介绍 windows上做开发,不管是cmd还是powershell,似乎都不够美观,不够强大.今天就来介绍一款可以替代cmd的神器"Cmder",话不多说, ...
随机推荐
- jQuery 工具函数
jQuery工具函数 一.$.browser对象属性 属性列表 说明 webkit webkit相关浏览器则返回true,否则返回false,如google,傲游. mozilla mozilla相关 ...
- Tomcat启动报:invalid LOC header (bad signature)的问题
原因:这种一般是因为项目依赖的某个jar包损坏引起的, 解决办法: 1.右键项目,选择maven,更新(update maven project) 2.通过右击项目名 -> Run as -& ...
- Linux 内核源码中likely()和unlikely()【转】
本文转载自:http://blog.csdn.net/tigerjibo/article/details/8279183 ikely()与unlikely()在2.6内核中,随处可见,那为什么要用它们 ...
- hdu acm 1114 Piggy-Bank 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1114 题目意思:给出一个空的猪仔钱ang 的重量E,和一个装满钱的猪仔钱ang 的重量F你,实质上能装 ...
- Unbuntu 终端中使用Tab键不能自动补全
解决方案 1.利用vi编辑器打开 /etc/bash.bashrc文件(需要root权限) sudo vi /etc/bash.bashrc 2.找到文件中的下列代码 #enable bash com ...
- 基于jQuery仿淘宝产品图片放大镜特效
在开发商城的时候,往往会用到图片的放大功能,这里把自己在近期项目中使用的放大镜特效做一下总结(非插件). 放大镜效果 常用的js组件jquery.imagezoom,jquery.jqzoom,jqu ...
- 用mkdirs创建目录
import java.io.*; class a { public static void main(String args[]) { createDir("c:/fuck"); ...
- POJ2142:The Balance (欧几里得+不等式)
Ms. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine. F ...
- BZOJ_2225_[Spoj 2371]Another Longest Increasing_CDQ 分治+树状数组
BZOJ_2225_[Spoj 2371]Another Longest Increasing_CDQ 分治+树状数组 Description 给定N个数对(xi, yi),求最长上升子 ...
- 怎样在github上协同开发
How to co-work wither parter via github. Github协同开发情景模拟 Github不仅有很多开源的项目可以参考,同样也是协同开发的最佳工具,接下来的就模拟一下 ...