PowerShell命令总结

 

使用HTTPS,自签名证书和ASP.NET Core在本地开发

参考这篇文章

https://www.humankode.com/asp-net-core/develop-locally-with-https-self-signed-certificates-and-asp-net-core

使用PowerShell部署ASP.NetCore程序到IIS

参考我的另一篇文章: 

https://blog.csdn.net/wucong60/article/details/85803663

或者参考:https://www.cnblogs.com/seriawei/p/8487441.html

Import-Module WebAdministration

Write-Host "Checking IIS status..."
$iis = Get-Service W3SVC -ErrorAction Ignore
if($iis){
    if($iis.Status -eq "Running") {
        Write-Host "IIS Service is running"
    }
    else {
        Write-Host "IIS Service is not running"
    }
}
else {
    Write-Host "Checking IIS failed, please make sure IIS is ready."   
}

$aspNetCoreModule = Get-WebGlobalModule -Name AspNetCoreModule -ErrorAction Ignore

if($aspNetCoreModule)
{
     Write-Host "IIS ASPNetCoreModule is ready:"
     Write-Host $aspNetCoreModule.Name $aspNetCoreModule.Image
}
else
{
    #download aspnetcoremodule
    Invoke-WebRequest -Uri "https://download.visualstudio.microsoft.com/download/pr/34f4b2a6-c3b8-495c-a11f-6db955f27757/8c340c1a8c25966e39e0c0a4b308dff4/dotnet-hosting-2.2.5-win.exe" -OutFile "dotnet-hosting-2.2.5-win.exe"
    Start-Process "dotnet-hosting-2.2.5-win.exe" -Wait  -ArgumentList '/S', '/v', '/qn' -passthru
    Write-Host "IIS ASPNetCoreModule is installed successfully"

}

$site =get-website|Where-Object {$_.Name -like '*mmcapi*'}

$siteName = $site.Name  # 27354_mmcapi-compliance.ciostage.accenture.com
$poolName =$site.Name
$physicalPath = $site.PhysicalPath   #D:\Apps\27354_mmcapi-compliance.ciostage.accenture.com

Write-Host 'site name:' $sitename ', pool name:' $poolName ', physical path:' $physicalPath

# 把应用程序池的.Net版本设置为无托管代码
Set-ItemProperty -Path IIS:\AppPools\$poolName -Name managedRuntimeVersion -Value ''

# Set identity user
Set-ItemProperty IIS:\AppPools\$poolName -name processModel.identityType -Value SpecificUser
Set-ItemProperty IIS:\AppPools\$poolName -name processModel.userName -Value $username
Set-ItemProperty IIS:\AppPools\$poolName -name processModel.password -Value $password
get-ItemProperty -Path IIS:\AppPools\$poolName -Name processmodel

# restart IIS
Invoke-Expression "net stop was /y"
Invoke-Expression "net start w3svc"

Start-WebAppPool -Name $poolName

查询 windows feature

Get-WindowsOptionalFeature -Online | WHERE {$_.FeatureName -like '*identity*'}

启用 windows feature

Enable-WindowsOptionalFeature -Online -FeatureName 'Windows-Identity-Foundation'

修改某个文件的内容

(type '1.txt') -replace ('aaa','bbb')|out-file 1.txt

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值