none
aasdfsadf RRS feed

Answers

  • Wow, don't remember TechNet ever being filled with condescending members before...but that's cool, I guess I see people need to learn manners on here \_(ツ)_/ 

    As far as your PS script, none of that works for me. Each computer at a site has a site code.
    Example: HINJ-%SerialNumber% 

    So what you published is not going to detect the site code of the hostname and tell the script which file to point to based off the hostname name. 

    For the record, I don't write this stuff for a living so please take your childish comments somewhere else. 

    (this was aimed towards JVR)

    • Edited by TheUsD Saturday, February 23, 2019 2:17 AM
    • Marked as answer by TheUsD Saturday, February 23, 2019 5:30 AM
    Saturday, February 23, 2019 2:10 AM

All replies

  • I see someone needs to learn PowerShell and basic Windows.

    $hosts = @{
        AMIK = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\amiklogin.bat'
        CRIC = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\criclogin.bat'
        FJIC = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\ftjesselogin.bat'
        HFDH = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\hfdhlogin.bat'
        HDSV = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\hfsvloging.bat'
        HINJ = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\hinjlogin.bat'
        ICWR = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\ICWRlogin.bat'
        LTR = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\ltrlogin.bat'
        MSBA = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\MSBAlogin.bat'
        MSBW = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\MSBWlogin.bat'
        MSLF = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\MSLFlogin.bat'
        MSTM = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\MSTMlogin.bat'
        NHI = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\NHIlogin.bat'
        ODCA = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\ATHlogin.bat'
        ODCK = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\ODCklogin.bat'
        ODCH = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\ODCHlogin.bat'
        ODCN = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\ODCNlogin.bat'
        SMIC = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\SMIClogin.bat'
    }
    
    $batfile = $hosts[$env:COMPUTERNAME]
    Write-Host $env:COMPUTERNAME $batfile
    start-process $batfile -argumentlist  $PWD,$batfile -Verb runas


    \_(ツ)_/


    • Edited by jrv Saturday, February 23, 2019 1:49 AM
    Saturday, February 23, 2019 1:49 AM
  • First of all - when you post code here in the forum please format this code as code using the code posting tool provided on the edit bar of the post editor. Thanks.

    I'd recommend for you to start to learn the very basics of Powershell. Since Powershell is an CLI just like CMD but much more powerful there's no need anymore to use batch files. Powershell is easily able to do everything what's been possible with batch. And Powershell code is easier readable and less repetitive and redundand when writtten clever.

    You should pay special attention to the switch statement. Here a short example how you could shorten your code:

    $PathTemplate = '\\mydomain.com\mdt\Deployments\Production\Applications\Imprivata\Autologin\#tmplt#login.bat'
    $result = switch -Wildcard ($ENV:ComputerName) {
        'ATH-*' {$PathTemplate -replace '#tmplt#', 'ODCA'; break }
        'AMIK-*' {$PathTemplate -replace '#tmplt#', 'AMIK'; break }
        'CRIN-*' {$PathTemplate -replace '#tmplt#', 'CRIC'; break }
        'ODCH-*' {$PathTemplate -replace '#tmplt#', 'ODCH'; break }
        'DHCH-*' {$PathTemplate -replace '#tmplt#', 'ODCH'; break }
        Default {$PathTemplate -replace '#tmplt#', 'BSC'}
    }
    $result

    This way you check the hostname of the computer the script runs on and saves the according path to the variable $result. The path will be build with a replace of the "substring" "#tmplt#" with the according string. This way your code would be easier to read and easier to maintain. Try it.

    Of course instead of creating the variable with the path to the old batch file you should do the actual task you do with the batch file at the moment. That would eliminate the need of several different files.

    And have a lot of fun. ;-) :-D


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''



    • Edited by BOfH-666 Saturday, February 23, 2019 2:19 AM
    Saturday, February 23, 2019 2:02 AM
  • Wow, don't remember TechNet ever being filled with condescending members before...but that's cool, I guess I see people need to learn manners on here \_(ツ)_/ 

    As far as your PS script, none of that works for me. Each computer at a site has a site code.
    Example: HINJ-%SerialNumber% 

    So what you published is not going to detect the site code of the hostname and tell the script which file to point to based off the hostname name. 

    For the record, I don't write this stuff for a living so please take your childish comments somewhere else. 

    (this was aimed towards JVR)

    • Edited by TheUsD Saturday, February 23, 2019 2:17 AM
    • Marked as answer by TheUsD Saturday, February 23, 2019 5:30 AM
    Saturday, February 23, 2019 2:10 AM
  • Wow, don't remember TechNet ever being filled with condescending members before...but that's cool, I guess I see people need to learn manners on here \_(ツ)_/ 

    As far as your PS script, none of that works for me. Each computer at a site has a site code.
    Example: HINJ-%SerialNumber% 

    So what you published is not going to detect the site code of the hostname and tell the script which file to point to based off the hostname name. 

    For the record, I don't write this stuff for a living so please take your childish comments somewhere else. 

    (this was aimed towards JVR)

    Please try to understand that the requirements of the forum need to be followed.  Flagging an answer as abusive because it is not what you want is childish.

    The question and code you posted shows a lack of any training in Windows and PowerShell.   The criticism is to help you undersztand haow you can better understand how to work with these technologies. If you are just looking for someone to do this for you then post in the following forum.

    Forum for Script   requests

    Please read all of the following links to understand how to use technical forums and for information on how to learn PowerShell at a technical level:

    Please carefully review the following links to set your expectation for posting in  technical forums.

    This Forum is for   Scripting   Questions Rather than script requests 

    How to ask   questions in a technical forum

    Forum for Script   requests

          Microsoft Virtual     Academy - Getting Started with Microsoft PowerShell

          PowerShell Documentation

          PowerShell Style   Guidelines

    Rubber duck problem solving

    How to write a bad forum post

    Help Vampires:  A  Spotter's Guide

    Understanding the above will help you to have a better experience with PoweerShell, technology and technical forums.


    \_(ツ)_/

    Saturday, February 23, 2019 2:29 AM


  • As far as your PS script, none of that works for me. Each computer at a site has a site code.
    Example: HINJ-%SerialNumber% 

    So what you published is not going to detect the site code of the hostname and tell the script which file to point to based off the hostname

    If you would actually learn PowerShell yu would know that this is the sitecode environment variable:

    $env:sitecode

    Which would give you this:

    $batfile = $hosts[$env:sitecode]

    Please take time to learn the basic technology and you will not percievt that answers are abusive.  Not knowing enough basics will make you feel like everything else is impossible to understand.  It is your responsibility to learn the technology  you want to work with.


    \_(ツ)_/


    • Edited by jrv Saturday, February 23, 2019 2:35 AM
    Saturday, February 23, 2019 2:35 AM
  • Wow, don't remember TechNet ever being filled with condescending members before...but that's cool, I guess I see people need to learn manners on here \_(ツ)_/ 

    As far as your PS script, none of that works for me. Each computer at a site has a site code.
    Example: HINJ-%SerialNumber% 

    So what you published is not going to detect the site code of the hostname and tell the script which file to point to based off the hostname name. 

    For the record, I don't write this stuff for a living so please take your childish comments somewhere else. 

    (this was aimed towards JVR)

    Please try to understand that the requirements of the forum need to be followed.  Flagging an answer as abusive because it is not what you want is childish.

    The question and code you posted shows a lack of any training in Windows and PowerShell.   The criticism is to help you undersztand haow you can better understand how to work with these technologies. If you are just looking for someone to do this for you then post in the following forum.

    Forum for Script   requests

    Please read all of the following links to understand how to use technical forums and for information on how to learn PowerShell at a technical level:

    Please carefully review the following links to set your expectation for posting in  technical forums.

    This Forum is for   Scripting   Questions Rather than script requests 

    How to ask   questions in a technical forum

    Forum for Script   requests

          Microsoft Virtual     Academy - Getting Started with Microsoft PowerShell

          PowerShell Documentation

          PowerShell Style   Guidelines

    Rubber duck problem solving

    How to write a bad forum post

    Help Vampires:  A  Spotter's Guide

    Understanding the above will help you to have a better experience with PoweerShell, technology and technical forums.


    \_(ツ)_/

    It was flagged as abusive because your childish comments are not warranted. Your script not being adequate is unrelated. If you're going to wear that moderator title, try learning respect... It goes a long way. To finish up your latest fruitless reply, no where did I ask anyone to re-write my script. I simply asked what I might need to modify to get the PS to run the bat as an admin. I guess reading plain text for you is equally as difficult as writing powershell is to me.
    Saturday, February 23, 2019 2:39 AM
  • It was flagged as abusive because your childish comments are not warranted. Your script not being adequate is unrelated. If you're going to wear that moderator title, try learning respect... It goes a long way. To finish up your latest fruitless reply, no where did I ask anyone to re-write my script. I simply asked what I might need to modify to get the PS to run the bat as an admin. I guess reading plain text for you is equally as difficult as writing powershell is to me.

    I repeat.  You need to learn basic Window technology and basic PowerShell.  Your posted code proves that.  We cannot teach you these things and if you want to believe you already know them then why are you asking such a trivial question.  Just think about it.

    Saying you don't know these things is just fact.  It is not an insult.  It is a fact you have to address to progress.

    Here is a good place to get some basic information about you issue: Advanced PowerShell basics


    \_(ツ)_/

    Saturday, February 23, 2019 2:45 AM
  • It was flagged as abusive because your childish comments are not warranted. Your script not being adequate is unrelated. If you're going to wear that moderator title, try learning respect... It goes a long way. To finish up your latest fruitless reply, no where did I ask anyone to re-write my script. I simply asked what I might need to modify to get the PS to run the bat as an admin. I guess reading plain text for you is equally as difficult as writing powershell is to me.

    I repeat.  You need to learn basic Window technology and basic PowerShell.  Your posted code proves that.  We cannot teach you these things and if you want to believe you already know them then why are you asking such a trivial question.  Just think about it.

    Saying you don't know these things is just fact.  It is not an insult.  It is a fact you have to address to progress.

    Here is a good place to get some basic information about you issue: Advanced PowerShell basics


    \_(ツ)_/

    Please just remove yourself from this thread. You've already proven to me you're useless and now you're clogging it up and continuing to provide nothing useful. You need to find something else to do tonight as some of us are actively seeking advice and help. Thanks! 
    Saturday, February 23, 2019 3:10 AM
  • Not! Didn't!

    \_(ツ)_/

    Saturday, February 23, 2019 3:17 AM
  • some of us are actively seeking advice and help. Thanks! 
    You have been given advice and help. I posted the answer to most of you impossible to understand question.  Did you even look at it?


    \_(ツ)_/

    Saturday, February 23, 2019 3:19 AM
  • some of us are actively seeking advice and help. Thanks! 

    You have been given advice and help. I posted the answer to most of you impossible to understand question.  Did you even look at it?


    \_(ツ)_/

    Your script didn't work. It wasn't the answer and you need to re-read what I posted to understand what I'm seeking. You obviously don't understand so you need to move along.
    Saturday, February 23, 2019 3:23 AM
  • Your script didn't work. It wasn't the answer and you need to re-read what I posted to understand what I'm seeking. You obviously don't understand so you need to move along.

    I read your post. You code has nothing about the registry. It is just a bunch of variables. It does not explain what the issue is.

    As a reminder this is your question: "Can anyone help me understand where I need to modify?"

    Where are you trying to modify the registry?   I see no registry code.  YOU seem to have a lot of batch files that are likely the issue.  This is not a batch forum.  Perhaps you need to post in a batch forum.


    \_(ツ)_/

    Saturday, February 23, 2019 3:33 AM