Powershell script call function based on value in excel cell

Absar 21 Reputation points
2020-08-05T16:21:32+00:00

I am looking for a way to take appropriate action or call function based on value in cell of excel.
e.g. if cell value has true then enable user for Skype Enterprise Voice and if value is false then first enable for Skype and then for EV as well. Similarly create other EV related objects e.g. CAP phone, RGS

can someone pls help what code should I write in script

Windows for business Windows Server User experience PowerShell
Microsoft 365 and Office Skype for Business Windows
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 47,901 Reputation points
    2020-08-06T18:46:25.42+00:00

    I don't know how you are representing True/False in your worksheet. So the "<true-value>" in code below may be a single digit "1" or a Boolean value TRUE, or just plain text "true", so make the necessary adjustment in the conditional statement.

    if ((<get-cell-value>) -eq <true-value>){
        # enable user for Skype Enterprise Voice
    }
    else{
        # enable use for Skype
        # enable user for Skype Enterprise Voice
    }
    
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2020-08-05T18:47:28.25+00:00

    Are you asking how to read data from an Excel file? Or are you asking how to determine what to do based on the data you read from an Excel cell? Or are you asking how to enable a user for Sykpe EV, or Skype, the EV, then some other things?

    If you want to read data from an Excel file you have two choices: use a COM object (which probably won't exist on a server), or use the ImportExcel module (a much better way . . . here's a link to explain and get you started read-and-write-excel-spreadsheets-with-the-importexcel-powershell-module .

    Once you've got the worksheet and checked the value in the cell, it's just a regular "if/then" statement in which you'll take the necessary actions.

    0 comments No comments

  2. Absar 21 Reputation points
    2020-08-06T13:26:30.77+00:00

    "are you asking how to determine what to do based on the data you read from an Excel cell "

    your above statement is what I am trying to achieve/do

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.