I have created a table in SQL with the following command: (bear with me, I am a newbie and after reading powershell in a month of lunches was able to do the following command successfully Thanks, but now, I am sooooooooooo stuck…and just need to be pointed in the right direction.
$date = get-date
$Data=Get-DhcpServerv4Lease -ScopeId 0.0.0.0 -ComputerName dhcp-ed | Select-Object -Property Updated,IPAddress,ScopID,AddressState,ClientID,ClientType,Description,DNSRegistration,DNSRR,HostName,LeaseExpiryTime,NapCapable,NapStatus,PolicyName,ProbationEnds,ServerIP
$connection = "Server=dashboard;Database=NetworkInventory;Trusted_Connection=True;"
Import-Module C:\Scripts\out-sql.psm1
$Data | out-sql -sqlserver "dashboard" -database "networkinventory" -table "DHCP2" -dropexisting $true
The property listed above named updated did not exist in the dhcpserverv4lease information. I added it to populate with a date, which I have already done.
Now, I need to:
$Data =Get-DhcpServerv4Lease -ScopeId 0.0.0.0 -ComputerName dhcp-ed
Update the table If the ClientID exists in $Data
If not
Add to the table and populate the updated filed with that current date.
And I have to tell you, I loved, LOVED your book "Powershell 3 in a Month of Lunches" It took me about 5 weeks to do. Having no experience, other than reading your book, I was at least able to figure out the above statement! I have purchased the toolmaking book and wish you had a powershell & SQL book. If you know of a good "beginner" book, please direct me. Thanks again!