tcox8 / OSD-Reporting

This script creates a webpage to show SCCM OSD Reporting
16 stars 5 forks source link

IIS Shows no content #16

Closed kneesliding closed 2 years ago

kneesliding commented 2 years ago

Hi,

I've set up the site as shown in the set up guide, but when the script runs, in IIS and webpage it just shows "No devices have been detected as starting the Task Sequence"

Am I missing something here?

tcox8 commented 2 years ago

Have you confirmed you have configured the correct TS information per the instructions? And have you confirmed you have imaged something with that said TS?

kneesliding commented 2 years ago

Hi, yes. Thats my Arguments line: -NoProfile -ExecutionPolicy Bypass -File "C:\Skripte\MECM\OSD-Reporting-master\osdreporting.ps1" -SQLServer "Z1TN" -Database "cm_PEW" -TSAdvertisementID "PEW2021C" -TaskSequenceID "PEW008BF" -IISPath "C:\inetpub\OSD" -MDM $False

kneesliding commented 2 years ago

Hi, Is possible that the information is missing as the clients are removed from the collection? But shouldnt the info still be visible as its the deployment ID History and not collection history?

kneesliding commented 2 years ago

Our SQL is on a seperate box with restricted access, what permissions would a Service account need for the accessing the CM SQL DB?

kneesliding commented 2 years ago

PS C:\Skripte\MECM\OSD-Reporting-master> .\osdreporting.ps1 -SQLServer "SQL" -Database "cm_PEW" -TSAdvertisementID "PEW2021C" -TaskSequenceID "PEW008BF" -IISPath "C:\inetpub\OSD\" -MDM "False" Cannot index into a null array. At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting.ps1:321 char:9

You cannot call a method on a null-valued expression. At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting.ps1:322 char:9

Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it is null. At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting.ps1:323 char:61

Cannot index into a null array. At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting.ps1:324 char:9

kneesliding commented 2 years ago

I've tried with $False also.

kneesliding commented 2 years ago

Shame really... just cant get it to work.

Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: '5 - @{Name=Apply Windows Settings}' Key being added: '5 - @{Name=Apply Windows Settings}'" At C:\Scripts\OSDReporting.ps1:438 char:53

Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: '6 - @{Name=Apply Network Settings}' Key being added: '6 - @{Name=Apply Network Settings}'" At C:\Scripts\OSDReporting.ps1:438 char:53

kneesliding commented 2 years ago

Screenshot 2021-11-26 134738

tcox8 commented 2 years ago

I’m traveling for the holiday this past week. I’ll be able to help on Monday. Sorry!

kneesliding commented 2 years ago

Thanks!

tcox8 commented 2 years ago

1) Can you post a screenshot of your task sequence steps?

2) And to answer your question about the Service Account. As noted in the instructions, it must be an administrator on the server and an administrator within the SCCM console. If your DB is on a separate server, I would start by adding that service account as a sysadmin to see if it works.

3) Please follow the comment here to make sure you are using the correct information for "TSAdvertisementID" and "TaskSequenceID". https://github.com/tcox8/OSD-Reporting/issues/14#issuecomment-859611063

kneesliding commented 2 years ago

Hi, Thanks for the Reply!

Service account is "Full Adnin" and also local admin. I've double checked the ID's, both are correct.

Here's the TS Steps.

Screenshot 2021-11-29 144107

tcox8 commented 2 years ago

Can you run powershell as Admin using that Service Account, or in VS Code, or in Powershell ISE? Set each of the parameters accordingly i.e. "$IISPath = "C:\inetpub\OSDReporting\wwwroot". After that, run the script.

From there, we will want to look at what is in the $Messages variable. Is it blank or does it have data? Please post a screenshot.

Next, look at the $TSSteps variable. Is it blank or does it have data? Please post a screenshot.

kneesliding commented 2 years ago
PS C:\Users\246136a> C:\Skripte\MECM\OSD-Reporting-master\OSDReporting_Test.ps1
cmdlet OSDReporting_Test.ps1 at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
SQLServer: Z1TN9181
Database: CM_PEW
TSAdvertisementID[0]: PEW2021C
TSAdvertisementID[1]: 
TaskSequenceID: PEW008BF
IISPath: C:\inetpub\OSD
Cannot index into a null array.
At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting_Test.ps1:321 char:9
+         $DriverIndexStart = $TSDriverSteps[0].name #Get the name of t ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

You cannot call a method on a null-valued expression.
At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting_Test.ps1:322 char:9
+         $index = $TSSteps.Name.IndexOf($DriverIndexStart)#Get the ind ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it is null.
At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting_Test.ps1:323 char:61
+ ... tepsNoDrivers = Compare-Object -ReferenceObject $TSSteps.Name -Differ ...
+                                                     ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Compare-Object], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.CompareObjectCommand

Cannot index into a null array.
At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting_Test.ps1:324 char:9
+         $TSStepsNoDrivers = $TSStepsNoDrivers[0..($index -1)] + "Inst ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

PS PEW:\> 
kneesliding commented 2 years ago

PS C:\Skripte\MECM\OSD-Reporting-master> .\OSDReporting_Test.ps1 -SQLServer "Z1TN9181.ew.zz" -Database "cm_PEW" -TSAdvertisementID "PEW2021C" -TaskSequenceID "PEW008BF" -IISPath "C:\inetpub\OSD" -MDM $False Cannot index into a null array. At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting_Test.ps1:321 char:9

You cannot call a method on a null-valued expression. At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting_Test.ps1:322 char:9

Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it is null. At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting_Test.ps1:323 char:61

Cannot index into a null array. At C:\Skripte\MECM\OSD-Reporting-master\OSDReporting_Test.ps1:324 char:9

PS PEW:>

kneesliding commented 2 years ago

This is the TS and ID's.

Screenshot 2021-11-29 150914

kneesliding commented 2 years ago

is that enough info?

tcox8 commented 2 years ago

This looks like it could be a database connection issue. I am seeing a lot of the arrays are null. Is there anything in the $statusmessages or $messages variables after running the script?

kneesliding commented 2 years ago

Where can I see that?

tcox8 commented 2 years ago

If you still have it up, just type "$StatusMessages" to see what is stored in that variable. And the same for $messages.

kneesliding commented 2 years ago

Screenshot 2021-11-29 152411

tcox8 commented 2 years ago

Ok. So that's blank. Means rather nothing has imaged or it isn't returning data from the database. Try adding the variable below to your line to run the script. Note: this is for testing only and don't include this in production. Here we are just saying, return everything within the past 180 hours.

-TimeInHours "180"

With that added, try seeing if anything is in the $messages variable again

kneesliding commented 2 years ago

Hi, Still blank.

kneesliding commented 2 years ago

If I run Status Message query in the MECM Console, it returns detailed info, so there is content in the tables

tcox8 commented 2 years ago

Are you an admin in MECM console and both servers? If so, can you run powershell under your account and see the results? This is looking more and more like a DB connection issue.

tcox8 commented 2 years ago

Also, what does the $TSSteps variable look like? It is separate from the DB connections and instead uses native MECM powershell functions.

kneesliding commented 2 years ago

This is running as my normal admin... Full all... Apperenatly..

PS PEW:> cd C:\Skripte\MECM\OSD-Reporting-master

PS C:\Skripte\MECM\OSD-Reporting-master> .\OSDReporting_Test.ps1 cmdlet OSDReporting_Test.ps1 at command pipeline position 1 Supply values for the following parameters: (Type !? for Help.) SQLServer: Z1TN9181.ew.zz Database: cm_PEW TSAdvertisementID[0]: PEW2021C TSAdvertisementID[1]: TaskSequenceID: PEW008BF IISPath: C:\inetpub\OSD MDM: False

PS PEW:> $StatusMessages

PS PEW:> $Messages

PS PEW:>

kneesliding commented 2 years ago

I'll get the SQL Team to recheck the permissions..

tcox8 commented 2 years ago

Please report back on your findings. Thanks!

kneesliding commented 2 years ago

Hi, Thanks so far!

I've set it up in my lab, seems to run, but I get the following when I run the script a second time...

Normal?

Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: 'Exit Task Sequence' Key being added: 'Exit Task Sequence'" At C:\Scripts\OSDReporting.ps1:423 char:37

Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: 'Exit Task Sequence' Key being added: 'Exit Task Sequence'" At C:\Scripts\OSDReporting.ps1:423 char:37

tcox8 commented 2 years ago

Those are normal. It's caused by duplicate entries of the words "exit task sequence" being added to the hash table. One day I'll get in there and clean that up. Once it is running as a scheduled task you won't see the errors any more. :-)

kneesliding commented 2 years ago

Doesnt seem to update..

Screenshot 2021-11-30 160029

tcox8 commented 2 years ago

What does the $messages variable look like now?

kneesliding commented 2 years ago

Screenshot 2021-11-30 160700

tcox8 commented 2 years ago

I can see from your screenshot there that the account you are running this under does not have access to "C:\inetpub\OSD\" folder. You'll need to correct that.

kneesliding commented 2 years ago

Screenshot 2021-11-30 161616

kneesliding commented 2 years ago

If i set the MDM to False, throws the error.

tcox8 commented 2 years ago

What does the $TSSteps variable look like?

kneesliding commented 2 years ago

Screenshot 2021-11-30 162152

kneesliding commented 2 years ago

but the status in the web shows no progress...

kneesliding commented 2 years ago

Screenshot 2021-11-30 162241

tcox8 commented 2 years ago

Is $messages still blank?

kneesliding commented 2 years ago

Yes.

tcox8 commented 2 years ago

Then we sill aren't talking to the database. Can you right-click and "run as" on the SCCM console to run as the account you are trying to run this under? From there, are you able to view status messages for this task sequence?

kneesliding commented 2 years ago

Yes, I'm logged on as the Enterprise admin with all rights on all systems.

tcox8 commented 2 years ago

Did you manually add your Enterprise Admin as a sysadmin on the Database? You would have to login to the SQL server and configure the permissions for that.

tcox8 commented 2 years ago

Note: Enterprise Admins are not usually workstation and server Administrators

kneesliding commented 2 years ago

its a lab setup. My User has SQL DBOwner permissions.

No difference, and tried with run as...

tcox8 commented 2 years ago

Open the script, copy line 80 through 229. Paste it in your PS window. Then look at the $table variable. That should be raw database data in that variable.

kneesliding commented 2 years ago

PS CHQ:> $table

RecordID : 72057594037969206 SeverityName : Informational Type : Milestone MessageID : 11128 Severity : 1073741824 MessageType : 256 ModuleName : SMS Client MsgDLLName : climsgs.dll Component : Task Sequence Engine MachineName : CLIENT1 Time : 11/30/2021 2:44:54 PM SiteCode : CHQ InsString1 : 4 InsString2 : Pre-provision BitLocker InsString3 : Install Operating System InsString4 : 0 InsString5 : InsString6 : InsString7 : InsString8 : InsString9 : InsString10 : RecordID1 : 72057594037969206 AttributeID : 401 AttributeValue : CHQ20004 AttributeTime : 11/30/2021 2:44:54 PM DateDiffer : 1

RecordID : 72057594037969205 SeverityName : Informational Type : Milestone MessageID : 11130 Severity : 1073741824 MessageType : 256 ModuleName : SMS Client MsgDLLName : climsgs.dll Component : Task Sequence Engine MachineName : CLIENT1 Time : 11/30/2021 2:44:54 PM SiteCode : CHQ InsString1 : 3 InsString2 : Partition Disk 0 - UEFI InsString3 : Install Operating System InsString4 : 0 InsString5 : InsString6 : InsString7 : InsString8 : InsString9 : InsString10 : RecordID1 : 72057594037969205 AttributeID : 401 AttributeValue : CHQ20004 AttributeTime : 11/30/2021 2:44:54 PM DateDiffer : 1

RecordID : 72057594037969204 SeverityName : Informational Type : Milestone MessageID : 11134 Severity : 1073741824 MessageType : 256 ModuleName : SMS Client MsgDLLName : climsgs.dll Component : Task Sequence Engine MachineName : CLIENT1 Time : 11/30/2021 2:44:54 PM SiteCode : CHQ InsString1 : 2 InsString2 : Partition Disk 0 - BIOS InsString3 : Install Operating System InsString4 : 0 InsString5 : ... drive: C: Skipping non-local logical drive: F: Adding logical drive: S: Skipping non-local logical drive: X: Formatting drive C: with NTFS filesystem, method quick Creating instance of service loader Loading service Waiting for service to initi InsString6 : alize Querying for software providers Found a VDS software provider Querying for IVdsSwProvider Querying for packs Found a VDS pack Querying for IVdsPack Querying for volumes Found a VDS software provider Querying for IVdsSwProvider Querying for InsString7 : packs Found a VDS pack Querying for IVdsPack Querying for volumes Found a VDS volume Querying for IVdsVolumeMF Querying for access paths Found a VDS pack Querying for IVdsPack Querying for volumes Found a VDS volume Querying for IVdsVolumeMF InsString8 : Querying for access paths Found a VDS volume Querying for IVdsVolumeMF Querying for access paths Found a volume with access path 'C:\' Querying for IVdsVolume Querying for IVdsVolumeMF Partition: 3 Recovery OSDDiskPart.exe completed successfully InsString9 : SMS_TaskSequence_PartitionDiskAction InsString10 : RecordID1 : 72057594037969204 AttributeID : 401 AttributeValue : CHQ20004 AttributeTime : 11/30/2021 2:44:54 PM DateDiffer : 1

RecordID : 72057594037969203 SeverityName : Informational Type : Milestone MessageID : 11130 Severity : 1073741824 MessageType : 256 ModuleName : SMS Client MsgDLLName : climsgs.dll Component : Task Sequence Engine MachineName : CLIENT1 Time : 11/30/2021 2:44:33 PM SiteCode : CHQ InsString1 : 1 InsString2 : Restart in Windows PE InsString3 : Install Operating System InsString4 : 0 InsString5 : InsString6 : InsString7 : InsString8 : InsString9 : InsString10 : RecordID1 : 72057594037969203 AttributeID : 401 AttributeValue : CHQ20004 AttributeTime : 11/30/2021 2:44:33 PM DateDiffer : 1

RecordID : 72057594037969202 SeverityName : Informational Type : Milestone MessageID : 11124 Severity : 1073741824 MessageType : 256 ModuleName : SMS Client MsgDLLName : climsgs.dll Component : Task Sequence Engine MachineName : CLIENT1 Time : 11/30/2021 2:44:33 PM SiteCode : CHQ InsString1 : 0 InsString2 : InsString3 : Install Operating System InsString4 : 0 InsString5 : InsString6 : InsString7 : InsString8 : InsString9 : InsString10 : RecordID1 : 72057594037969202 AttributeID : 401 AttributeValue : CHQ20004 AttributeTime : 11/30/2021 2:44:33 PM DateDiffer : 1

RecordID : 72057594037969201 SeverityName : Informational Type : Milestone MessageID : 11144 Severity : 1073741824 MessageType : 256 ModuleName : SMS Client MsgDLLName : climsgs.dll Component : Task Sequence Engine MachineName : CLIENT1 Time : 11/30/2021 2:44:33 PM SiteCode : CHQ InsString1 : 0 InsString2 : InsString3 : InsString4 : 0 InsString5 : InsString6 : InsString7 : InsString8 : InsString9 : InsString10 : RecordID1 : 72057594037969201 AttributeID : 401 AttributeValue : CHQ20004 AttributeTime : 11/30/2021 2:44:33 PM DateDiffer : 1

RecordID : 72057594037969200 SeverityName : Informational Type : Milestone MessageID : 11140 Severity : 1073741824 MessageType : 256 ModuleName : SMS Client MsgDLLName : climsgs.dll Component : Task Sequence Engine MachineName : CLIENT1 Time : 11/30/2021 2:44:33 PM SiteCode : CHQ InsString1 : 0 InsString2 : InsString3 : InsString4 : 0 InsString5 : InsString6 : InsString7 : InsString8 : InsString9 : InsString10 : RecordID1 : 72057594037969200 AttributeID : 401 AttributeValue : CHQ20004 AttributeTime : 11/30/2021 2:44:33 PM DateDiffer : 1