Fixed link for your blog post: https://keithga.wordpress.com/1418
-- Espi On Fri, Sep 15, 2017 at 8:43 PM, Keith Garner <keith.gar...@hotmail.com> wrote: > Interesting… > > > > Decided to Tackle the problem… > > > > https://wordpress.com/post/keithga.wordpress.com/1418 > > > > Within the blog post is a script that will allow you to update one or more > CS.ini files over the network (as long as you have the correct permissions). > > > > -k > > > > *From:* listsad...@lists.myitforum.com [mailto:listsadmin@lists. > myitforum.com] *On Behalf Of *David Landry > *Sent:* Friday, September 15, 2017 12:29 PM > > *To:* scripting@lists.myitforum.com > *Subject:* [scripting] RE: bat file will only run one time > > > > Thanks Keith. > > > > I really like what you are doing here with the random generated password. > I just wish I had the knowledge to completely understand what you were > doing and how to implement it … something to work towards. > > > > Thanks again to everyone …. I have the script working great thanks to > everyone’s help. > > > > My manager is the Global Ops Manager and now he is asking me to find a way > to run it on about 50 servers worldwide so the other MDT admins don’t have > to log onto each server just to add one line. > > > > > > Still working my way thru that one …. > > > > > > > > > > *From:* listsad...@lists.myitforum.com [mailto:listsadmin@lists. > myitforum.com <listsad...@lists.myitforum.com>] *On Behalf Of *Keith > Garner > *Sent:* Wednesday, September 13, 2017 12:40 AM > *To:* scripting@lists.myitforum.com > *Subject:* [scripting] RE: bat file will only run one time > > > > PowerShell: > > > > First you will need a function to write to an INI file: > > https://github.com/keithga/DeploySharedLibrary/blob/ > master/DeployShared/Windows/Set-PrivateProfileString.ps1 > > > > Next you will need a function to write to your Bootstrap or > CustomSettings.ini file: > > > > https://github.com/keithga/DeploySharedLibrary/blob/ > master/DeployShared/MDT/Set-MDTCustomSettings.ps1 > > > > Additionally, what about a function to randomly generate a password: > > > > https://github.com/keithga/DeploySharedLibrary/blob/ > master/DeployShared/Windows/New-UserPassword.ps1 > > > > Now tie it all together. > > > > Here is an example of a script I wrote. I wanted to create a boot.iso > image that could connect to a MDT deploymentShare using a non-interactive > account on the local machine. (an account that you can’t log into, and is > not a member of any group, the only thing it can do is allow you to connect > to the deployment share). > > > > The script will generate a random password string, set MDTUser with that > password, and then place that password within the bootstrap.ini file, > finally updating the deployment share to include that password. When the > ISO image was created, we would reset all the values. > > > > https://github.com/keithga/DeployShared/blob/master/ > Hydrate/ShareOperations/2%20-%20Create%20Boot%20Images%20(test).MDT.PS1 > > > > Additionally, in your code below, there is no “next” statement to close > out the for each loop. > > > > -k > > > > *From:* listsad...@lists.myitforum.com [mailto:listsadmin@lists. > myitforum.com <listsad...@lists.myitforum.com>] *On Behalf Of *David > Landry > *Sent:* Tuesday, September 12, 2017 11:15 AM > *To:* scripting@lists.myitforum.com > *Subject:* [scripting] bat file will only run one time > > > > Hi All, > > > > I will admit up front, my script write abilities are slim. I have this > script that I found to insert a new line of text into an .ini file and it > works perfectly …. But for just one time. During my testing I removed the > inserted line and text and then reran the script. Only this time it didn’t > do anything. Nothing got inserted. After rerunning this a dozen times or so > I can’t figure out why. > > > > I tried this on a Windows 10 and a Windows 7 system with same behavior. It > ran only once on each system. > > > > set objWS = CreateObject("Wscript.Shell") > > Set fsob=CreateObject("Scripting.FileSystemObject") > > > > strNewLine = "AdminPassword=@dm1n1$trat0r!" > > strFileName = "C:\test\script\CustomSettings.ini" ' for example > c:\textfile.txt > > > > Const FOR_READING = 1 > > Const FOR_WRITING = 2 > > strCheckForString = UCase("SkipAdminPassword=YES") > > Set objFS = CreateObject("Scripting.FileSystemObject") > > Set objTS = objFS.OpenTextFile(strFileName, FOR_READING) > > strContents = objTS.ReadAll > > objTS.Close > > arrLines = Split(strContents, vbNewLine) > > Set objTS = objFS.OpenTextFile(strFileName, FOR_WRITING) > > For Each strLine In arrLines > > If (Left(UCase(LTrim(strLine)),Len(strCheckForString)) = > strCheckForString) Then > > objTS.WriteLine strLine > > objTS.WriteLine strNewLine > > else > > objTS.WriteLine strLine > > End If > > > > Can anyone explain this to me? What needs to be changed? > > > > Thanks in advance > > > > Dave L. > > > > > > > >