Search found 91 matches

by miketartaglia
Thu Dec 28, 2017 7:27 am
Forum: Windows PowerShell
Topic: Trouble with multiple Device ID's (Local Hard drives)
Replies: 43
Views: 5906

Re: Trouble with multiple Device ID's (Local Hard drives)

Sorry for the lack of clarity. the START switch only enters start date, start time and current free space at that time on each local disk. This leave 3 fields set to NULL. Endate, EndTime and EndSpace (current free space at the time on each local disk. All the end switch is supposed to do and did do...
by miketartaglia
Wed Dec 27, 2017 2:56 pm
Forum: Windows PowerShell
Topic: Trouble with multiple Device ID's (Local Hard drives)
Replies: 43
Views: 5906

Re: Trouble with multiple Device ID's (Local Hard drives)

Yes that is what I show while in the debugger with a breakpoint.

I think if I query on the ID field (auto incremented field) in the view, I may be able to use a where command in the sql statement.
by miketartaglia
Wed Dec 27, 2017 2:42 pm
Forum: Windows PowerShell
Topic: Trouble with multiple Device ID's (Local Hard drives)
Replies: 43
Views: 5906

Re: Trouble with multiple Device ID's (Local Hard drives)

That made some progress. Now all the EndSpace fields in three rows are identical numbers which is impossible since it is looking at different volumes and servers.
by miketartaglia
Wed Dec 27, 2017 1:42 pm
Forum: Windows PowerShell
Topic: Trouble with multiple Device ID's (Local Hard drives)
Replies: 43
Views: 5906

Re: Trouble with multiple Device ID's (Local Hard drives)

This is what I have but this doesn't look right.

$tmplt = @'
UPDATE dbo.NoendDate (EndDate, EndTime, EndSpace)
VALUES('{0}', '{1}', '{2}')
'@
by miketartaglia
Wed Dec 27, 2017 11:44 am
Forum: Windows PowerShell
Topic: Trouble with multiple Device ID's (Local Hard drives)
Replies: 43
Views: 5906

Re: Trouble with multiple Device ID's (Local Hard drives)

Invoke-Sqlcmd -ServerInstance $sqlserver -Database $database -Username $sqluser -Password $sqlpass -Query $query
by miketartaglia
Wed Dec 27, 2017 10:59 am
Forum: Windows PowerShell
Topic: Trouble with multiple Device ID's (Local Hard drives)
Replies: 43
Views: 5906

Re: Trouble with multiple Device ID's (Local Hard drives)

Here is the error at run time after credentials are entered ERROR: Invoke-Sqlcmd : Incorrect syntax near '('. SQLSpace2.ps1 (46, 4): ERROR: At Line: 46 char: 4 ERROR: + Invoke-Sqlcmd -ServerInstance $sqlserver -Database $datab ... ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ER...
by miketartaglia
Wed Dec 27, 2017 8:41 am
Forum: Windows PowerShell
Topic: Trouble with multiple Device ID's (Local Hard drives)
Replies: 43
Views: 5906

Re: Trouble with multiple Device ID's (Local Hard drives)

Param ([switch]$start, [switch]$end ) $sqlserver = "SQLAG" $database = "DriveSpace" $sqluser = "DriveSpace" $sqlpass = "SOMEPASSWORD" if ($start) { $creds = Get-Credential $servers = get-content servers.txt $tmplt = @' INSERT into SQLSpace(SystemName, DeviceID, StartDate, StartTime, StartSpace) VAL...
by miketartaglia
Wed Dec 27, 2017 8:21 am
Forum: Windows PowerShell
Topic: Trouble with multiple Device ID's (Local Hard drives)
Replies: 43
Views: 5906

Re: Trouble with multiple Device ID's (Local Hard drives)

Here is my modified code. I can not get the end switch to work. Param ([switch]$start, [switch]$end ) $sqlserver = "SQLAG" $database = "DriveSpace" $sqluser = "DriveSpace" $sqlpass = "Connectme" if ($start) { $creds = Get-Credential $servers = get-content servers.txt $tmplt = @' INSERT into SQLSpace...
by miketartaglia
Tue Dec 26, 2017 8:00 am
Forum: Windows PowerShell
Topic: Trouble with multiple Device ID's (Local Hard drives)
Replies: 43
Views: 5906

Trouble with multiple Device ID's (Local Hard drives)

Below is the code I use to insert free drive space into a SQL database. However, it will only work if the server it is looking at only has one drive in it (For example C: drive only). If there is an additional hard drive, it will skip that drive. I don't want to re-write the entire script, but I cou...
by miketartaglia
Thu Dec 01, 2016 12:43 pm
Forum: Windows PowerShell
Topic: Need to send an email when MessageCount is greater than $threshold
Replies: 8
Views: 1918

Re: Need to send an email when MessageCount is greater than $threshold

Any idea what I'm doing wrong? This is probably Powershell 101 stuff. sorry