How to Update DNS Records Programatically - powershell

I am trying to update a DNS Record which is at (I believe) the following path on the server:
ServerName -> Forward Lookup Zones -> domain.com -> test
Where the DNS record is called test, and is of type Host(A).
I downloaded the DNSShell module from here and tried changing the 'Data' column of the DNS record (which contains an IP address) with this command:
Set-DNSRecord -Identity "test.domain.com"
But I got this error:
Cannot validate argument on parameter 'Identity'. The argument "test.domain.com" does not match the "^\\.\root\MicrosoftDNS:MicrosoftDNS_" pattern. Supply an argument that matches "^\\.\root\MicrosoftDNS:MicrosoftDNS_" and try the command again.
So I updated the Identity parameter as follows:
Set-DNSRecord -Identity "\\Servername\root\MicrosoftDNS:MicrosoftDNS_"
But now I am seeing:
Set-DNSRecord : Specified argument was out of the range of the valid values. Parameter name: Path
When I try adding a -Path, it says there is not such parameter! Does anyone know where I need to add the test.domain.com part of the DNS to tell the command which record to update? The documentation on this module is incomplete for this part of it and I can't seem to find any alternatives.
I can call Get-DNSRecord and see the record I need to update, but any attempts to Set are blocked because I have no idea how these paths are built.
Any help is much appreciated.

You can use also default PowerShell module for DNS server from Microsoft, example would then look something like this:
Add-DnsServerResourceRecordA -Name "recordname" -IPv4Address "192.168.0.0" -ZoneName "domain.com" -AllowUpdateAny -AgeRecord
In case you need removal before that something like this should work:
Remove-DnsServerResourceRecord -ZoneName "domain.com" -Name "recordname" -RRType "A" -Force

I managed to overcome this by using ye olde classic CMD command:
dnscmd /RecordAdd domain.com recordname RecordType /Aging /OpenAcl A 192.168.0.0
This adds a new record, and seems to do so even when another record with the same name (but different IP) exists.
So in my case, I will have to use dnscmd to first remove the existing record before adding a new one (as I actually just want to update the IP address of the existing record).
Command for removing dns record :
dnscmd /recorddelete domain.com recordname
More details can be found here.

Related

Assign ITGlue Contact to the Field using API powershell

I just want to assign the contacts to Application's field and another field with API Powershell but I don't know how to do it. could anyone help me?
According to their API documentation, there is no 'Application' resource type. Is it a custom resource, or a field on a different type of object? (what type?)
Try installing ITGlue's PowerShell wrapper module ITGlueAPI from the gallery (or github link):
Install-Module ITGlueAPI
Import-Module ITGlueAPI
# Check out all the available commands
Get-Command -Module ITGlueAPI
# initial setup:
Add-ITGlueBaseURI -base_uri 'http://myapi.gateway.example.com'
Add-ITGlueAPIKey -ApiKey 'your-key-here'
# Play around with these kinds of "Get-" commands which exist for each resource type:
# This is a good way to see how the data is formatted, and which fields exist per resource
Get-ITGlueFlexibleAssets
Get-ITGlueContacts -organization_id 1234 -filter_first_name 'Foo' -sort 'first_name'
# To make changes, run similar "Set-" or "New-" commands with the updates in hash table format:
Set-ITGlueContacts -id 1234 -data #{
location-id = 795
location-name = "San Francisco - HQ"
field-name = "Value"
}

Attempting to connect to Firebird 2.5 database, getting "-service path\database.FDB:service_mgr" is not defined

I'm trying to run a trace using
fbtracemgr -SE "localhost:C:\Users\user1\Desktop\db.FDB:service_mgr" -user SYSDBA -password masterkey -start -name "to" -config "C:\Users\user1\traceparameter.conf" > c:\Users\user1\dboutput.txt
Cannot attach to services manager
-service C:\Users\user1\Desktop\db.FDB:service_mgr is not defined
Any ideas why this might be?!
I've also tried without :service_mgr and I get the same result.
If I refer to a non existing database (used a random db.FDB filename) I get the same result, so it seems to not be related to the db itself at all?
You need to specify -SE localhost:service_mgr or - local only - -SE service_mgr. The service_mgr specifies you connect to the "Service Manager" of Firebird, not to a specific database. In other words, the database name does not belong in that connection string.
See also Audit and Trace Services in Firebird 2.5.

How to get the computers domain name in matlab?

I tried getting domain name in c# as below,
IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
Console.WriteLine("Domain name: {0}", properties.DomainName);
I have searched similar kind of approach in matlab for finding domain name. But I am not successful. Could anyone help me out like how we can get the domain name matlab(The domain name looks like yyy.xxxxx.com).
I got to know how to get computer name as below:
cc=getenv('computername');
How about this:
[s,cout] = system('net config workstation | findstr /C:"Full Computer name"');
FQDN= strtrim(strrep(cout,'Full Computer name',''))
FQDN=
XXXX.YYYY.com
This returns the fully qualified domain name (FQDN) of the computer . Where XXXX is your PC Name and YYYY is the domain.
Similarly if you just want the domain name:
[s,cout] = system('systeminfo | findstr /C:"Domain:"');
Domain = strtrim(strrep(cout,'Domain:',''))
Domain =
YYYY.com
EDIT: You can also get the FQDN using java in matlab like this:
FQDN = java.net.InetAddress.getLocalHost.getCanonicalHostName
FQDN =
XXXX.YYYY.com
You can read from the environment variable:
getenv('USERDOMAIN')

ldapmodify: Invalid parameter ... specified for changetype modify

I'm using a script that is supposed to add an attribute to an LDAP record. It used to work, then we moved the LDAP server from Solaris Unix to Linux.
Now the script doesn't work and throws an error
The LDIF file looks like this :
dn:cn=template-uid,ou=Groups,o=mycompany.com,o=Company
changetype:modify
mgrpRFC822MailMember:new#gmail.com
ldapmodify gets called like this :
ldapmodify -h ldap.mycompany.com -D "cn=LDAPuser" -w *pswd* -v -p 636 -f updateUser.ldif
This is the error that gets thrown :
ldapmodify: Invalid parameter "mgrpRFC822MailMember" specified for changetype modify
If I log into LDAP using an LDAP browser with the same user, I can manually add the attribute without any problem. I just can't do it from command line.
Any ideas ?
Thanks
Assuming it should add a value to mgrpRFC822MailMember, it should be:
dn: cn=template-uid,ou=Groups,o=mycompany.com,o=Company
changetype: modify
add: mgrpRFC822MailMember
mgrpRFC822MailMember: new#gmail.com
A changetype of modify needs an action defined, which would be one of: add, delete, replace. That is then followed by the attribute name to take the action on. I'm surprised it worked at all in the previous form.

Use AppCmd to LIST CONFIG in APPHOST only

I have a requirement to use powershell to configure IIS7.5 on WebApplications that have not yet had code deployed (possibly at all, possibly old/broken web.configs exist) to the file system. I would like to be able to do this all at the APPHOST level. (Note at the bottom about use of Powershell > AppCmd).
I can SET all the values properly, however, being somewhat diligent, I like to also validate the values were set properly by retrieving them after setting.
Here's the scenario:
I can set this value using AppCmd so the setting is applied at the APPHOST level using the /Commit:APPHOST flag. However, I havent found a way to READ the values exclusively at the APPHOST level.
Setting the Code is successful:
C:\Windows\System32\inetsrv\appcmd.exe set config "webSiteName/webAppName" -section:system.webServer/security/authentication/anonymousAuthentication /enabled:"True" /commit:apphost
However, I cant find a way to read the values using AppCmd (or Powershell):
Running the following AppCmd returns an error due to the broken pre-existing web.config in the folder (the specific error is unimportant, as it is reading the WebApp's web.config instead of the ApplicationHost.config/APPHOST):
C:\Windows\System32\inetsrv\appcmd.exe list config "MACHINE/WEBROOT/APPHOST/webSiteName/webAppName" -section:system.webServer/security/authentication/anonymousAuthentication
ERROR ( message:Configuration error
Filename: \\?\c:\inetpub\wwwroot\webSiteName\webAppName\web.config
Line Number: 254
Description: The configuration section 'system.runtime.caching' cannot be read because it is missing a section declaration
. )
Note: I would prefer to do this all in Powershell instead of using AppCmd, so if anyone has the syntax for modifying the APPHOST settings for anonymousAuthentication section of a WebApplication, that lives under a Website, from inside Powershell (Get-WebConfiguration seems to only use the WebApp web.config), that would be totally awesome and much appreciated!
Here's how to do this in PowerShell:
[Reflection.Assembly]::Load(
"Microsoft.Web.Administration, Version=7.0.0.0,
Culture=Neutral, PublicKeyToken=31bf3856ad364e35") > $null
$serverManager = New-Object Microsoft.Web.Administration.ServerManager
$config = $serverManager.GetApplicationHostConfiguration()
$anonymousAuthenticationSection = $config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "simpleasp.net")
Write-Host "Current value: " $anonymousAuthenticationSection["enabled"]
# Now set new value
$anonymousAuthenticationSection["enabled"] = $true
$serverManager.CommitChanges()