Sometimes you will want to monitor a folder for changes, and possibly export a file list to Excel for consumption in some other format, or perhaps as part of a notification workflow.

I adapted a Powershell script to export a file list using a selected file extension as a filter, and also export some file properties like Directory and LastWriteTime (Date Modified).

Here is the Powershell script:

$arr = @()
gci L:DIRECTORY -include *.nwc -recurse | ? {$_.PSIsContainer -eq $False} | % {
$obj = New-Object PSObject
$obj | Add-Member NoteProperty Directory $_.DirectoryName
$obj | Add-Member NoteProperty Name $_.Name
$obj | Add-Member NoteProperty LastWriteTime $_.LastWriteTime
$arr = $obj
}
$arr | Export-CSV -notypeinformation "C:TARGETFOLDERLOwnCloudWIP.csv"
Copy-Item "C:TARGETFOLDERLOwnCloudWIP.csv" "C:UsersLuke JohnsonGoogle DriveGOOGLEDRIVERFOLDERLOwnCloudWIP.csv" -force
<code>

Put the above in a text document and save with the .ps1 extension

Quick summary of how it works:

  1.  As it is a powershell script, you will need powershell installed and it will need to be enabled with appropriate permission etc to access the network.
  2. Set up the script as per text above
  3. Set up Windows task scheduler to call the script periodically. Each time:
    1. Script runs and creates a CSV of filenames and dates etc in the monitored folder
    2. This automatically syncs (using the Copy-Item step) to Google Drive where it is shared with a gd url
    3. The gd url of the csv file is imported into another Google Spreadsheet, where ARRAY formulas are performed on it to create additional filter parameters based on file name

This ‘filterable’ Google sheet was shared with an ‘lv’ key so that it could be easily filtered by recipients. I think the new Google Sheets allow per user filtering, so that step may be unnecessary now.

You may need to set some additional arguments in the Windows task:

arguments.png

The scheduled task looks like this:

task.png

Warning: some have had unexpected results, use with care.
Update: one reader discovered that  C:Program FilesAutodeskRevit 2015AddIns is yet another path that Revit uses. The script below has not been modified to act on that path, but if you have problems after running the tool, perhaps moving the items out of this folder to a backup folder will help. This user had the following errors in the Journal:
“managed exception occurred” and “An item with the same key has already been added” and ExceptionCode=0xe0434352

… If you are experiencing a problem with Revit starting up, it could be due to a problem with one or more of your addins. As you probably know, Revit looks in a couple of key directories for *.addin files, and then it loads your addins based on what it finds. Also, in current versions of Revit it also looks in an ApplicationPlugins folder at the .bundle folders.

I created a Powershell script that looks in each of these three folders (for Revit 2015) and then renames the addin files and bundle folders, meaning that you can then open Revit 2015 in “addin-free mode”. The script requires that you are loading addins from the default AppData and ProgramData folders.

Important note: there are two scripts that are intended to work as a toggle, and for troubleshooting purposes only. After you run the Enable script, do not run it again. Make sure you run the Disable script next.

Here is the intended workflow:

  1. Download and unzip the ps1 files
  2. Ensure all Autodesk products are closed
  3. Run the 1_DisableRevitAddons.ps1 script to disable all Revit 2015 addins
  4. Start Revit
  5. If it starts, you know that some addin is causing your problem
  6. Close Revit
  7. Run the 2_EnableRevitAddons.ps1 script to restore the addin and bundle folder names

You can download both Powershell scripts here

Here is a quick Screencast showing it in action:

And some sample code for the disable script:

 cd $env:ALLUSERSPROFILEAutodeskRevitAddins2015  
Dir | Rename-Item –NewName { $_.name –replace “.addin“,”.addin.disabled” }
cd $env:ALLUSERSPROFILEAutodeskApplicationPlugins
Dir | Rename-Item –NewName { $_.name –replace “.bundle“,”.bundle.disabled” }
cd $env:APPDATAAutodeskRevitAddins2015
Dir | Rename-Item –NewName { $_.name –replace “.addin“,”.addin.disabled” }

After running the Disable script, you will end up with something like this:

Important: This is an extreme troubleshooting measure, and should be used with great care. Use at your own risk!

Here are some of the warnings / errors from the Powershell output. Some of these are due to the fact that I had Navisworks open and it could not rename those *.bundle folders. Various Autodesk products share the ApplicationPlugins folder, so it may have some unintended consequences on other products. Having said that, it seemed to work ok on my system.

Install and Run Windows Powershell

Give yourself unrestricted script access:

Set-ExecutionPolicy Unrestricted

Make a list of IPs to query and put it in a text file (1 IP per line).

Modify script below and put it in a text file with extension .ps1 (like script.ps1)

$ErrorActionPreference = 'SilentlyContinue'
$computers = Get-Content g:scriptipaddress.txt
foreach($computer in $computers) {
$ping = Test-Connection -ComputerName $computer -Count 1 -Quiet
$computerName = [system.net.dns]::Resolve("$computer")
#$hostname = $computerName.HostName
$shortHostname = $computerName.HostName.Split(".")[0]
if ($ping -eq 'True')
{
$UserName = (Get-WmiObject -ComputerName $computer win32_ComputerSystem).UserName
Write-Host "$shortHostname $UserName" -ForegroundColor Green
#Write-Host "$hostname is pingable" -ForegroundColor Green
}
else
{
Write-Host "$computer is not pingable" -ForegroundColor Red
}
}

Put the .txt and the.ps1 in the same folder.

Browse to the folder in Powershell.

Type .script.ps1

Wait for the query to find all the logged in users on your IP range…

from
Power ping and get computer, username