Tags

, ,

Hi Friends,

A script in the “PowerShell for Beginners” series.

One of the main reasons to write this script was to find the expired Sitecore license from the whole wwwroot. If you are working on Sitecore, you may know that the Sitecore developer license expires in August. We had the new license file but we missed updating it to XDB sites in the developer machine. So to avoid this kind of mistake, I wrote a PowerShell script that will output the file path and file date in a txt file.

You can use this script to find any file you want.

The script finds all the files mentioned in the "double quotes". And writes its path and last updated date time in a file "license.xmlpath.txt". Both parameters can be changed to your requirement. 

To run the below script:

  1. Open PowerShell prompt
  2. If you know how and where to run the script, Run line no 4 from the below script (Highlighted) else You can type/copy the below script in PowerShell prompt.
c:
cd\
cd .\inetpub\wwwroot\
gci -include "license.xml" -file -recurse  | %{$_.FullName,$_.LastWriteTime} > licensexmlpath.txt

You can find some more properties on the Microsoft site.

https://docs.microsoft.com/en-us/dotnet/api/system.io.filesysteminfo?view=net-6.0