简体   繁体   English

如何通过Powershell更新AppDynamics .net代理?

[英]How do I update AppDynamics .net agent via Powershell?

not new to coding but I have been working in python before and shaking the rust off my Powershell and working with xml. 不是新编码,但我之前一直在使用python工作,并在我的Powershell中使用xml进行抖动。 We are trying to automate the deployment of AppDynamics's .net agent and we have the deployment piece down as well as upgrade. 我们正在尝试自动部署AppDynamics的.net代理,我们还有部署和升级。 Now I am trying to include specific applications and tiers running on IIS. 现在我尝试包含在IIS上运行的特定应用程序和层。 So again shaking off rust here but I am trying the find a simple script to update the config.xml to add the application and update the tier from IIS. 所以再次摆脱生锈但我正在尝试查找一个简单的脚本来更新config.xml以添加应用程序并从IIS更新层。 It's not a complex xml file but any help or direction would be helpful 它不是一个复杂的xml文件,但任何帮助或方向都会有所帮助

Just trying to find the right syntax to update the nodes properly and arguments 只是试图找到正确的语法来正确更新节点和参数

#Current work
$config = "mylocation\config.xml"
$configuration = $config
[xml]$xml = New-Object XML
$xml.load($configuration)
#what will make this work !!! I have tried a few things but it's been a 
while and I am having to read up on xml again :|
$xml.Save($configuration)

 #what I need updated <?xml version="1.0" encoding="utf-8"?> <appdynamics-agent xmlns:xsd="http://stuff.com" xmlns:xsi="http://stuff.com"> <controller host="test.saas.appdynamics.com" port="123" ssl="true" enable_tls12="true"> <applications> #need to create this <application default="true" name="app1" /> #need to add the default='true' if there is more than one app <application name="App2"/> #this </applications> #this <account name="testacct" password="123456" /> </controller> <machine-agent /> <app-agents> <IIS> <applications> #there by default with the default settings <application controller-application="app1" path="/app1path" site="WebSite1"> # need to add this <tier name="app1-1" /> #and this </application> #this too <application controller-application="app2" path="/app2path" site="WebSite2"> #some more <tier name="app2-2" /> #you guessed it </application> #this as well </applications> #ends with this </IIS> </app-agents> </appdynamics-agent> 

You are on the right track, but you are not saying that you are having errors or showing the. 你走在正确的轨道上,但你并不是说你有错误或表现出来。 Yet, based on your experience to date, I am sure you already know that PowerShell provides cmdlets for working with XML. 然而,根据您迄今为止的经验,我确信您已经知道PowerShell提供了用于处理XML的cmdlet。

See them using --- 用---看他们

Get-Command -Name '*xml*' | ft -a  

or get other XML modules from the MS PowerShellGallery.com using --- 或使用---从MS PowerShellGallery.com获取其他XML模块

Find-Module -Name '*xml*' | ft -a 

--- and install the one(s) that fit your needed goals. ---并安装符合您所需目标的那个。

And of course there are lot's of examples and videos on the topic. 当然,有很多关于这个主题的例子和视频。 Searching for 'PowerShell working with XML', gives you plenty of hits. 搜索“PowerShell使用XML”,为您提供了大量的点击量。

PowerShell Data Basics: XML PowerShell数据基础:XML

For the most part, what you will find is very similar to what you already have posted. 在大多数情况下,您将找到的内容与您已发布的内容非常相似。 Yet, you say you want add nodes / elements, but that is not in your post, so, something like the below should help. 然而,你说你想要添加节点/元素,但这不在你的帖子中,因此,类似下面的内容应该有所帮助。

$xml = [xml](Get-Content C:\file.xml)
$elem = $xml.Configuration.ConfigSections.AppendChild($xml.CreateNode([System.Xml.XmlNodeType]::Element,'section',$null))
$elem.SetAttribute('name','something')
$xml.Save('C:\file.xml')

Or even just using the WebAdministration module on the IIS server directly. 甚至只是直接在IIS服务器上使用WebAdministration模块

You should check out the AppDynamics agent installation PowerShell Extension: https://www.appdynamics.com/community/exchange/extension/dotnet-agent-installation-with-remote-management-powershell-extension/ 您应该查看AppDynamics代理安装PowerShell扩展: https//www.appdynamics.com/community/exchange/extension/dotnet-agent-installation-with-remote-management-powershell-extension/

It should be able to handle what you are trying to do without having to generate the xml manually, check the pdf for advanced options and read about the Add-IISApplicationMonitoring cmdlet 它应该能够处理你想要做的事情而不必手动生成xml,检查pdf以获取高级选项并阅读Add-IISApplicationMonitoring cmdlet

What it can't do is the newer stuff like “multiple business application” and “custom node name” configuration. 它不能做的是更新的东西,如“多业务应用程序”和“自定义节点名称”配置。 (Which you can't do in the install wizard either) (你也无法在安装向导中执行此操作)

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

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