I have a Javascript value in my Webpart and I want to use this value in my PowerShell script! Is it possible?


function RetrieveLog() {
    var getItemsUrl = "/_api/Web/Lists/GetByTitle('" + ListName +"')/items?$select= ID,Title,LastDD,Current_x0020_DD_x0020_status&$orderby=Date1 desc&$top=1";

    var promise = $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + getItemsUrl,
        type: "GET",
        headers: {
            "accept": "application/json;odata=verbose",
        success: function (data) {
            ArrayRetrieved = data.d.results;
            if (ArrayRetrieved.length > 0) {
                for (var i = 0; i < ArrayRetrieved.length; i++) {

                  if (ArrayRetrieved[i].Current_x0020_DD_x0020_status == "Signed-off")

                        $("#LastDD").text(moment(ArrayRetrieved[i].LastDD).format('DD MMM YYYY'));

        error: function (error) {
            console.log("Error on Retrieve log");


For this, I want to get the value of $("#LastDD") in PowerShell.


No, you cannot get that specific value from the script since it is only executed in the browser.

The script loads items from a list, checks if a status field is set to "signed-off" and attaches the value of a corresponding date (LastDD) to some element on the page (only for the last item in the list. bug?)

You can at least read the same value with powershell.

Here is an example for how to get list items:


You would only need to add your own logic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.