Hi guys, so basically my overall goal is to query 5 servers and export a list of users who accessed the machine out: Targetusername, IP address/source computer/ time and out to spread sheet. It would be helpful to only get back the last time a user connected. Method invocation failed because does not contain a method named substring System Center 2012 Configuration Manager Configuration Manager 2012 - Application Management.
I want to search and replace a string in an xml file using PowerShell.I tried this: (gc d:test.xml).replace('1234','xxxx') sc d:test.xmlThis works fine for my test.xml file. The content of my test.xml file is:uehjduehduhfeuf xxxxxxxx hallo '1234'But that file is only for testing. I want to edit a server.xml form my tomcat server in this way and if I'm using exactly the same command mentioned obove I get this error message:Method invocation failed because System.Object doesn't contain amethod named 'replace'.Does anybody know what's the problem?
Can you post the entire script? I am not sure this is the correct forum for this question, it is probably more suited for a PowerShell forum, but I don't know how to move threads or if I am allowed to.It is hard to say exactly what your problem is without seeing the full exception or full code block. What is setting $RetiringApp for example, what line # is the error occurring, etc.I am making the assumption String$RetiringApp.Substring is throwing your exception.
How is that variable being set? Since you are typecasting the variable as a string I would expect the substring method to be present though.Manually setting $RetiringApp using your code works fine, so i think there is something else going on that requires more information.i.e. $RetiringApp = 'testString123'$ShortRApp = (string$RetiringApp.Substring(0,$RetiringApp.length-3))write-host $ShortRApp.