-1

I am very inexperienced in scripting and any help would be much appreciated. We are creating secured exam accounts for our school district and need to automate password changes.

Here is the sheet I am working on - https://docs.google.com/spreadsheets/d/1eOn-5ysDKrAEag3o73fT2-GMcFBiO4PBUo2GKN8e72A/edit#gid=628591826

Basically I want to create a script that will reset and randomize all passwords (8 char, #'s and lowercase) everyday at a specific time. I am familiar with setting up triggers, and got a few other scripts to work but I can't figure out how to apply it to the entire range (d2:d).

Any help or direction would be greatly appreciated.

Stephen

Rubén
  • 34,714
  • 9
  • 70
  • 166

1 Answers1

1
function randoPasswords() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();//get spreadsheet
  var sheet = ss.getActiveSheet();//get sheet
  var range = sheet.getRange("D2:D");//get column
  var rows = range.getValues().length;//get number of rows
  for (var i=0; i < rows; i++)

   sheet.getRange("D"+(i+2)).setValue(makePw());//set value of each row

}


//from http://stackoverflow.com/questions/1349404/generate-random-string-characters-in-javascript
function makePw()
{
    var text = "";
    var possible = "abcdefghijklmnopqrstuvwxyz0123456789";

    for( var i=0; i < 9; i++ )
        text += possible.charAt(Math.floor(Math.random() * possible.length));
    return text;
}
Tom Woodward
  • 1,653
  • 14
  • 21
  • There are other ways of achieving the goal, but I see no big issues with this approach, seems solid to me as well. – Vytautas Oct 06 '16 at 08:28