Skip to content

Instantly share code, notes, and snippets.

@hansgafriedzal
Created September 20, 2021 04:35
Show Gist options
  • Save hansgafriedzal/89c28db940414a23b66c0a8c6c18ee19 to your computer and use it in GitHub Desktop.
Save hansgafriedzal/89c28db940414a23b66c0a8c6c18ee19 to your computer and use it in GitHub Desktop.
$path = "https://<tenant>.sharepoint.com/sites/<site>/<library>/<file>.xlsx"
$worksheetNames = ""
$save = $true
$excel = new-object -comobject excel.application
$timestamp = Get-Date -format "yyyyMMddHHmmss"
try
{
$workbook = $excel.Workbooks.Open($path)
if (!$workbook) {continue}
$workbook.Worksheets | %{
$_.activate()
$_.Range('d6').Value2 = $timestamp
$_.usedrange.rows | %{
$_.cells | %{
$_.Value2
}
}
}
}
catch
{
$_
$excel.visible = $true
}
$workbook.Close($save)
$excel.DisplayAlerts = $false
$excel.Quit()
if (!$test)
{
while([System.Runtime.Interopservices.Marshal]::ReleaseComObject($workbook)){}
while([System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel)){}
}
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment