简体   繁体   English

PowerShell Sript设置IIS环境变量

[英]PowerShell sript to set IIS environment variable

How can I automate the following steps by using PowerShell? 如何使用PowerShell自动执行以下步骤? :

  1. Go to IIS and choose a website (website name will most likely be passed down in script as a parameter) 转到IIS并选择一个网站(该网站名称很可能作为参数传递给脚本)
  2. Go Inside the Configuration Editor 进入配置编辑器 在此处输入图片说明
  3. Choose the aspNetCore Section in the dropdown 在下拉菜单中选择aspNetCore部分 在此处输入图片说明
  4. Go inside the environmnetVariables 进入环境变量 在此处输入图片说明
  5. Add new Collection 新增收藏 在此处输入图片说明
  6. Create new environment varialbe 创建新的环境变量 在此处输入图片说明

Thanks to Lex Li, Seems like Configuration Editor generates scripts automatically before savings. 感谢Lex Li,好像Configuration Editor这样的文件在保存之前会自动生成脚本。 This has lead me to getting the final PS script to be: 这使我获得了最终的PS脚本:

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/WEBSITENAME'  -filter "system.webServer/aspNetCore/environmentVariables" -name "." -value @{name='EnvironmentVariableName';value='EnvironmentVariableValue'}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM