Shell to PowerShell Code conversion

Looking for help in finding an equal PowerShell script for below shells script.

##################################################################################################################
# Logical Implementation of the files and its meta file/supporting file based on the folder name
#staticresources/classes/triggers/email - Get the relevant meta files for the files checked in
##################################################################################################################
if [ “${DNAME1}” == “staticresources” -o “${DNAME1}” == “classes” -o “${DNAME1}” == “triggers” -o “${DNAME1}” == “email” ];then
if [ echo "$FNAME" | grep -v "\-meta" ];then
echo “did not match”
FILE_BASE=echo $FNAME | awk -F "." '{print $1}'
FILE_EXT=echo $FNAME | awk -F "." '{print $2}'
FNAME_META=echo ${FILE_BASE}"."${FILE_EXT}"-meta.xml"
#FNAME_META=echo $FNAME| sed 's/\(.*\.\).xml/\1-meta.xml/' #assets.resource-meta.xml
fi

     #Copy the meta files from DNAME
     echo FNAME_META=$FNAME_META
      cp -rp ".""${file}" ${TEMPDIR}/${DNAME}/${FNAME}  || echo "No file found: ${file}"
      cp -rp ".""${DNAME}/${FNAME_META}" ${TEMPDIR}/${DNAME}/${FNAME_META} || echo "No file found: ${file}"
   ##################################################################################################################
    #aura - If any file changed under aura, copy the entire folder
   ##################################################################################################################
    elif [ "${DNAME1}" == "aura" ];then
      #Copy the folder to tmp directory
      cp -rp "."${DNAME} ${TEMPDIR}${DNAME}/.. || echo "No file found: ${file}"
    else
       #Copy only the checked in files
       cp -rp ".""${file}" "${TEMPDIR}/${DNAME}/${FNAME}"  || echo "No file found: ${file}"
    fi
 else
   #Copy only the checked in files
   cp -rp ".""${file}" "${TEMPDIR}/${DNAME}/${FNAME}"  || echo "No file found: ${file}"
  fi
done

I dont think you will find someone here to port this directly. Someone familiar with Linux/Bash might offer to help. It might be easier to define what you want to do with PowerShell and get help for that.

2 Likes