メールアカウントが設定されていない場合にのみ問題が発生する - それでも解決策があれば幸いです
助けが必要です。この小さなスクリプトの非常に奇妙な癖を見つけました。そして、なぜこれが起こるべきなのか、私にはまったく手がかりがありません。以下に投稿されたコードを実行すると、Microsoft Outlookが起動します。そして、Outlookプロセスを終了しない限り、スクリプトは動かなくなります! なぜこのコードは Outlook を起動するのでしょうか? 迷っています!
$Path = "C:\test.xls"
#Excelvar:
$Row = [int] 2
$Excel = New-Object -ComObject Excel.Application
$Excel.Visible = $true
$Excel.DisplayAlerts = $false
#Sheets:
$ADUsers = "Active Directory Users"
$Groups = "Create Groups"
$UsertoGroup = "User to groups"
$DNS = "DNS"
#$Worksheet = $Workbook.Sheets.Add()
$checkxls = test-path -pathtype Any $Path
if ($checkxls -eq $false) {
$wb = $Excel.Workbooks.Add()
$wb.Worksheets.add()
$wb.SaveAs($Path)
$wb.Close()
$Excel.Quit()
事前にthx!
Outlook が終了した後の Powershell 出力:
Application : Microsoft.Office.Interop.Excel.ApplicationClass
Creator : 1480803660
Parent : System.__ComObject
CodeName :
_CodeName :
Index : 1
Name : Tabelle4
Next : System.__ComObject
OnDoubleClick :
OnSheetActivate :
OnSheetDeactivate :
PageSetup : System.__ComObject
Previous :
ProtectContents : False
ProtectDrawingObjects : False
ProtectionMode : False
ProtectScenarios : False
Visible : -1
Shapes : System.__ComObject
TransitionExpEval : False
AutoFilterMode : False
EnableCalculation : True
Cells : System.__ComObject
CircularReference :
Columns : System.__ComObject
ConsolidationFunction : -4157
ConsolidationOptions : {False, False, False}
ConsolidationSources :
DisplayAutomaticPageBreaks : False
EnableAutoFilter : False
EnableSelection : 0
EnableOutlining : False
EnablePivotTable : False
FilterMode : False
Names : System.__ComObject
OnCalculate :
OnData :
OnEntry :
Outline : System.__ComObject
Rows : System.__ComObject
ScrollArea :
StandardHeight : 15
StandardWidth : 10,71
TransitionFormEntry : False
Type : -4167
UsedRange : System.__ComObject
HPageBreaks : System.__ComObject
VPageBreaks : System.__ComObject
QueryTables : System.__ComObject
DisplayPageBreaks : False
Comments : System.__ComObject
Hyperlinks : System.__ComObject
_DisplayRightToLeft : False
AutoFilter :
DisplayRightToLeft : False
Scripts : System.__ComObject
Tab : System.__ComObject
MailEnvelope :
CustomProperties : System.__ComObject
SmartTags : System.__ComObject
Protection : System.__ComObject
ListObjects : System.__ComObject
EnableFormatConditionsCalculation : True
Sort : System.__ComObject
PrintedCommentPages : 0