Using Powershell to create Pervasive database

In my quest to replace a bunch of old scripts and programs (blend of VB, bat files, manual intervention) to automate some processes, I'm trying to create a pervasive.sql database with Powershell. They currently use an old VB script to do this, and the code
is as follows:
Function CreatedB(strPath,strDDFPath,strdBName)
 Set mdtoDatabase = CreateObject("DTO.DtoDatabase.2")
 With mdtoDatabase
  mdtoDatabase.DataPath = strPath
  mdtoDatabase.DdfPath = strDDFPath
  mdtoDatabase.Name = strdBName
  mdtoDatabase.Flags = iFlags
 End With
 result = mdtoSession.Databases.Add(mdtoDatabase)
 If result > 0 Then
  msgbox "Error Adding DBN. Result: " & cstr(result)
  If cstr(result) = 7012 Then
  Else
   strDBMsg = strDBMsg & "NEED ATTENTION: Error adding DB " & strdBName & ". Result: " & cstr(result)
  End If
 End if
End Function
Seems pretty simple! However, I'm not sure how to, or if I can, get this ported to Powershell directly. Not sure that PS has the ability to work with DTO ? I could sure use some guidance on this one...I am open to other suggestions as well. I've been looking
at possibly using ado.net, but that seems to connect to "existing" dbs, and I can't really see anything to actually create a new db.
Thanks in advance!
mpleaf

JRV, by telling me it "was" possible, and giving me the above, I was able to use the get-member to figure out which aspects I needed, and I was actually able to do this! Guess I understood it a little better than I thought! Thanks for the nudge!
$Path = 'E:\myPath'
$DDFPath = 'E:\myPath'
$dBName = 'myDb'
$Flags = 0
$TaskUser = 'MyUser'
$TaskPass = 'MyPass'
$mdtoSession = New-Object -ComObject DTO.DtoSession
$connected = $mdtoSession.connect('localhost', $TaskUser, $TaskPass)
if ($mdtoSession.connected)
    echo 'connected'
    $mdtoDatabase = New-Object -ComObject DTO.DtoDatabase
    $mdtoDatabase.DataPath = $Path
    $mdtoDatabase.DdfPath = $DDFPath
    $mdtoDatabase.Name = $dBName
    $mdtoDatabase.Flags = $Flags
    $mdtoSession.Databases.Add($mdtoDatabase)
    else
    echo 'no go'
...and voila! My db was created!
mpleaf

Similar Messages

  • How to use MySQL to create a database

    I downloaded MySQL and opened the folder and saw a plethora of files. I'm lost and don't know where to start. I want to create a database. Any suggestions? I have dreamweaver cs5. My computer is a mac book pro OS10.6.8.

    To amplify osgood_'s excllent suggestions - MySQL is a database application that runs, typically, in a server environment. Full stop.
    This is not a simple "install the app and everything's good" type of program. Please do more research before attempting to install it. Also understand the security implications of running a database on a server (or even locally) and learn how to lock it down. Finally, to install and run MySQL locally, you better get really good with Terminal.app and learn how to launch MySQL and configure it from the command line.
    I personally use MAMP (Mac Apache MySQL and PHP - see http://www.mamp.info/) to do MySQL/PHP development and testing as it doesn't mess with the internals of my machine, keeps everything in a MAMP folder in my Applications folder, and it has a control panel for easy start/stop of Apache/MySQL services.
    Not trying to squash your dreams of running MySQL locally but you do need more "domain" knowledge before doing so.
    Hope this helps.

  • SCCM 2012 use PowerShell to create a GlobalCondition, limiting the Deployment Type of an Application to certain operating systems.

    Title says it all basically.
    In the GUI im able to create a Global Condition (condition type: Expression) where I can add a clause that Limits the deployment type of an application to certain operating Systems (useful for deploying 64-bit apps).
    Is there away to Trigger that Setting using PowerShell? So far I haven't found one.
    Thx in advance...

    I changed my script a little bit and can be found Here. 
    An example to use it is:
    #Get Application named "Test" from the Server "localhost"           
    $app = Get-SCCMApplication "Test" "localhost"
    #A rule will be created from the global condition rule "ForumTest" where the registry value equals to "1"
    $rule1 = Create-SCCMGlobalConditionsRule . "ForumTest" "IsEquals" 1 "Registry"
    #Add the rule to the requirement rule of the deployment type
    $app.DeploymentTypes[0].Requirements.Add($rule1)
    #And save the application
    Save-SCCMApplication $app
    PowerShell, System Center 2012, Windows 8 http://blog.lechar.nl
    Thanks Rob!
    Have unfortunately encountered some problems:
    Get-SCCMApplication does not exist. Changed it to Get-CMApplication
    Create-SCCMGlobalConditionsRule - Cant find any "Create..." cmdlets
    Save-SCCMApplication does not exist
    Get-CMApplication : A positional parameter cannot be found that accepts argument 'TestApp'.
    At H:\sctipt\SetRequirement.ps1:2 char:9
    +  $app = Get-CMApplication "TestApp" "siteServe ...
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Get-CMApplication], ParameterBindingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ConfigurationManagement.Cmdlets.AppMan.Commands.GetApplicationCommand
    Create-CMGlobalConditionsRule : The term 'Create-CMGlobalConditionsRule' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At H:\script\SetRequirement.ps1:5 char:11
    +  $rule1 = Create-CMGlobalConditionsRule . "GlobalRuleName" "IsEquals" 1 "Registry"
    +           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (Create-CMGlobalConditionsRule:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    Cannot index into a null array.
    At H:\script\SetRequirement.ps1:8 char:2
    +  $app.DeploymentTypes[0].Requirements.Add($rule1)
    +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : NullArray
    Save-CMApplication : The term 'Save-CMApplication' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the na
    me, or if a path was included, verify that the path is correct and try again.
    At H:\script\SetRequirement.ps1:12 char:1
    + Save-CMApplication $app
    + ~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (Save-CMApplication:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

  • Use Apex to create 2nd database

    I already have Oracle 10g and Apex working fine on my Windows XP box.
    Now my user has altered their requirements causing me to need to create a 2nd "database" using same named tables as already exist in my 1st "database".
    Can this be done? Am I using the correct terminology saying "database" rather than maybe "connection"?

    I created a PHP system for them using their Oracle 6 database tables. They have now upgraded their environment to Oracle 7 with, I suspect, some alterations to their column names.
    On my development machine I have a connection to s6s which is equavelent to their 1st version. I now want to create s7s containing the same tables as the s6s and carry on developing on that. I do not want to loose the s6s as the maintenance/support I have to do may well require this.
    I hope that the above is a bit more clear.

  • Creating a Scheduled Task using PowerShell v4

    So here is my question.  I'm trying/wanting to create a scheduled task using PowerShell v4 on Server 2012R2.  I want to task to run on the 1st day of every month.  The parameter for -Monthly -Day is not available.  I need to use PowerShell
    to create the Scheduled Task because the Task will be running with a group Managed Service Account credentials so the Scheduled Task can not be created via the Task Scheduler GUI.
    Thanks in Advance

    Here is a functioning task It can be easily edited in PowerShell or in notepad to alter the timing
    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.1" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
    <RegistrationInfo>
    <Author>W8TEST\user01</Author>
    </RegistrationInfo>
    <Triggers>
    <CalendarTrigger>
    <StartBoundary>2014-06-04T21:31:32.0459499</StartBoundary>
    <Enabled>true</Enabled>
    <ScheduleByMonth>
    <DaysOfMonth>
    <Day>1</Day>
    <Day>12</Day>
    <Day>24</Day>
    </DaysOfMonth>
    <Months>
    <January />
    <February />
    <March />
    <April />
    <May />
    <June />
    <July />
    <August /
    <September />
    <October />
    <November />
    <December />
    </Months>
    </ScheduleByMonth>
    </CalendarTrigger>
    </Triggers>
    <Principals>
    <Principal id="Author">
    <RunLevel>LeastPrivilege</RunLevel>
    <UserId>W8TEST\jvierra</UserId>
    <LogonType>InteractiveToken</LogonType>
    </Principal>
    </Principals>
    <Settings>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <IdleSettings>
    <StopOnIdleEnd>true</StopOnIdleEnd>
    <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
    </Settings>
    <Actions Context="Author">
    <Exec>
    <Command>notepad.exe</Command>
    <Arguments>test.txt</Arguments>
    <WorkingDirectory>c:\temp</WorkingDirectory>
    </Exec>
    </Actions>
    </Task>
    I have edited and reloaded the XML many, many times.  It works very nicely.
    ¯\_(ツ)_/¯

  • How to create a database using Java?

    Hi there..
    I'm a student who is currently studying IT and was asked to do a project based on database but create using Java.. since i'm a beginner..i was wondering whether is it possible to do that?
    and if it is possible.. can you kindly show me a sample of code on how to start the project...
    thank you
    yours sincerely,
    Shafini

    While duffymo is correct in regard to most major database products, it's my understanding (warning! wild-ass guess coming) that the Hypersonic DB is more "application-centric" and the dynamic creation of databases is part of its design. It's pure Java database software, and therefore is not appropriate for all database projects, in particular those that require extremely high-performance.
    See http://hsqldb.org/
    I've not used it yet (but soon though), and I can't really advise anyone about it.
    However, I'm wondering if you phrased you question in a way that is confusing us. To most of us in casual conversation, a "database" is both (1) a large organized collection of data and (2) the software that is used to organize and access it. However, the phrase "create a database" usually means creating a (1) database (a collection of data) using an already created (2) database software, such as Oracle, MySQL, DB2, HSQDB, etc., etc. If you'r question is, how do a create some new database software using Java, the answer is that this is a very very big and hard thing to do for the general case and probably not something you want to be doing.

  • How to create sql database using java frame or appelet?

    hi ! i am working on database project i want to create a database using java frame or applet where it asks user to select the location for database to be created , after user have specified the path then the programs creates the database, again i want that database to be read and write by another frame or applet but as user select the path how do i make the connectivity. i just have basic knowledge on java. please give me idea how can i process further.
    thanks a lot

    While duffymo is correct in regard to most major database products, it's my understanding (warning! wild-ass guess coming) that the Hypersonic DB is more "application-centric" and the dynamic creation of databases is part of its design. It's pure Java database software, and therefore is not appropriate for all database projects, in particular those that require extremely high-performance.
    See http://hsqldb.org/
    I've not used it yet (but soon though), and I can't really advise anyone about it.
    However, I'm wondering if you phrased you question in a way that is confusing us. To most of us in casual conversation, a "database" is both (1) a large organized collection of data and (2) the software that is used to organize and access it. However, the phrase "create a database" usually means creating a (1) database (a collection of data) using an already created (2) database software, such as Oracle, MySQL, DB2, HSQDB, etc., etc. If you'r question is, how do a create some new database software using Java, the answer is that this is a very very big and hard thing to do for the general case and probably not something you want to be doing.

  • Create two databases in one oracle home

    Hi All,
    I am new in oracle, using oracle standard edition 10g and some questions I want to ask.
    Is it possible to create 2 different databases under same oracle home? For example, one database for online transaction named orcl_online, one database for reporting services named orcl_report.
    If it is ok, that means 2 instance exist for each database, then how to use sqlplus to connect to orcl_online only ?
    Thanks.

    Not 2, you can create more number of databases in an Oracle Server but of course depend on the h/w configurations.
    Use dbca to create the database orcl_online and then again create orcl_online.
    If u trying to connect to particular DB through Command line, set the ORACLE_SID.
    In windows set ORACLE_SID= orcl_online then use sqlplus
    In unix/linux etc export ORACLE_SID=’ orcl_online’ then use sqlplus
    If using sqlplus GUI specify the host string which is the database name probably.

  • Custom AD Attributes using powershell

    Hi,
    Is it possible to create custom attributes using powershell v2/v3 ?
    Marcel

    Marcel,
    Active Directory Cookbook, 3rd Edition has a way to do it. Unfortunately, they do not include the crucial step of assigning the new attribute to the class. My company has multiple developers each with their own VM and we need to be able to do this hundreds
    of times internally and for our clients. I have been struggling for weeks trying to find the final piece. (recipe 10.7). Please let me know if you can figure out the last step
    Using PowerShell
    To create a schema attribute using the Quest tools, use the
    new-QADObject
    cmdlet as
    follows:
    new-QADObject -ParentContainer 'cn=schema,cn=configuration,
    <ForestRootDN>'
    -type
    'attributeSchema' -name 'adatum-LanguagesSpoken' -ObjectAttributes
    @{lDAPDisplayName='adatum-LanguagesSpoken';
    attributeId='1.3.6.1.4.1.999.1.1.28.3';oMSyntax='20';attributeSyntax='2.5.5.4';
    isSingleValued='FALSE';description='Language a user speaks';searchFlags='1'}
    To create a schema attribute using native PowerShell functionality, use the following
    syntax:
    $root = [ADSI]"LDAP://RootDSE"
    $schema = $root.schemaNamingContext
    $parentCont = [ADSI]("LDAP://" + $schema)
    $newAttr = $parentCont.Create("attributeSchema","adatum-LanguagesSpoken")
    $newAttr.put("lDAPDisplayName","adatum-LanguagesSpoken")
    $newAttr.put("attributeId","1.3.6.1.4.1.999.1.1.28.3")
    $newAttr.put("oMSyntax", 20)
    $newAttr.put("attributeSyntax", "2.5.5.4")
    $newAttr.put("isSingleValued", $false)
    $newAttr.put("description", "Languages a user speaks")
    $newAttr.put("searchFlags", 1)
    $newAttr.SetInfo()
    Discussion
    To create an attribute, you need to add an
    attributeSchema
    object to the
    Schema
    container.
    Typically, when you extend the schema, you perform several additions or modifications
    at once. The order of your extensions is very important. You can’t create a
    class, assign an attribute, and then create the attribute; you obviously need to create
    the attribute before it can be assigned to the class.
    Bud - MCITP

  • ORA-01034 when trying to create a database

    I successfully installed Oracle 8.1.7 on Solaris 8, but when I tried creating a database (by executing sql<SID>.sh after I ran "dbassist"), this error appeared:
    ORA-01034: Oracle not available.
    I could not use svrmgrl to do a startup because there is NO database.
    What services have to run before I can create a database?
    Thank you.
    null

    I chose "custom installation" and not to create a database during installation. There was no error when I installed the Oracle software and I modified the /etc/system (shmmax, shmmin, etc.) according to the Oracle documentation. After that, I used "dbassist" to create a database. Then the "ORA-01034: Oracle not available" appeared.
    I also tried to install Oracle with "Typical" option that is suppose to create the initial database for me. It also failed. The same error appeared when the 'Database Configuration Tools' were trying to create the database files.

  • Changing a SQL Report server Database to a new One Using Powershell script

    Hi,
    I have an existing report server (Native Mode) and a pre-configured report server database. I have created a new database and want to assign it new report server database. How can i automate this process using powershell?
    Here is the detail requirement
    If there is a Report Server database seeded on the xxxxx server, follow the below steps:
    ◾Click the Database button on the left. Click on the Change Database button, choose option Choose an existing report server database. Enter the RPT server name (e.g. xxxxxx) in Server Name text box and click Next.
    ◾In the Report Server Database selection, select the ReportServer database. Then click next button to complete the process.
    Any help in this regard will be very much helpfull.
    Sushruta Banerjee

    Hi Sushruta,
    To query export from Report server Database, the scripts below may be helpful for you:
    Export RDL Files from ReportServer Database with PowerShell
    SQL Database Reports with PowerShell
    I hope this helps.

  • Changing Content Database using Powershell

    Hi,
    I have a web application created. I have a another content DB, which I want to associate to the existing web application.
    I mean, the existing content db should be removed and the new Content db attached.
    What are the steps to achieve the same using powershell?
    Thanks

    Hi,
    For your issue, you can
    Dismount-SPContentDatabase and Mount-SPContentDatabase.
    A typical command to detach a database would be:
    Dismount-SPContentDatabase -Identity <contentdb>
    A typical command to attach a content database would be:
    Mount-SPContentDatabase -Name <contentdb> -DatabaseServer <dbserver> -WebApplication <webappname>
    Here is a link about
    Managing SharePoint Content Databases with PowerShell, you can use as a reference:
    http://www.mssqltips.com/sqlservertip/2608/managing-sharepoint-content-databases-with-powershell/
    Best Regards,
    Lisa Chen
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Creating multiple mailboxes using Powershell for users who already exist in AD

    Hi there,
    Wondering if anyone can help, I am wanting to use Powershell to run a command which references a CSV file to create a mailbox for a user who already exists in AD.
    It needs to reference the username, to ensure the correct user has a mailbox created (as mentioned they exist already in the domain), place them on a specific database (e.g DB1) and assign them an email address as well as possibly an alias email address
    too.
    Can anyone provide me the headings of the CSV file which would be needed as well as the powershell command to run. It would be great too if I could also set the quota sizes for the user at the same time of creating the mailbox, but if not possible or complicated
    I can run a script afterwards to do this. I would only want to warn them when their mailbox is 1.5GB in size and stop them sending when it reaches 2GB. 
    Thanks

    So create a csv file with the following headers and data
    UserID, Alias
    UserID should be the user SamAccountName, and the Alias is the Mailbox Alias that you want to set. Supposing that the csv file is named users.csv and located under C:\ , open the Exchange Management Console and run:
    $users = Import-Csv c:\users.csv
    Foreach ($user in $users) {
    Enable-Mailbox -Identity $user.UserID -alias $user.alias -database 'DB1'
    Set-Mailbox -Identity $user.UserID -IssueWarningQuota 1.5gb -ProhibitSendQuota 2gb 
    Please Mark As Answer if this helps
    ammarhasayen

  • ERROR WHILE CREATING A DATABASE LINK USING HETEROGENEOUS SERVICES

    I'm creating a database link with the Oracle Dataware Builder, and i get the following error:
    Probando...
    Fallo.
    SQL Exception
    Error del repositorio: Excepción SQL.
    Nombre de la Clase: CacheMediator.
    Nombre del Método: getDDEntryFromDB.
    Mensaje de Error del Repositorio: ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC][Informix][Informix ODBC Driver][Informix]Incorrect password or user [email protected] is not known on the database server. (SQL State: 28000; SQL Code: -951)
    ORA-02063: preceding 2 lines from PRUEBA_SEH
    As you can see i'm using heterogeneus services to connect to a informix database. ALTIADM is a valid user for that database, i don't send my ip address 192.168.0.62, but the error says "[email protected] is not known in the database server". how can i solve it?????

    Right places to ask this question are
    Heterogeneous Connectivity
    Warehouse Builder

  • Create SharePoint 2010 Search Service Application Using Powershell

    Hi Team,
    Could you please assist me in completing the search service application for
    two server using powershell. Both the servers will be running all the component
    Version SharePoint 2010
    # 1.Setting up some initial variables.
    write-host 1.Setting up some initial variables.
    $SSAName = "Search Service Application"
    $SVCAcct = "Domain\ServiceAccount"
    $SearchAppPoolName ="DefaultAppPool"
    $SSI = get-spenterprisesearchserviceinstance -local
    $err = $null
    $SSADBName="Search_AdminDB"
    $SSADBServer="DBServer"
    $host1="Server1"
    $host2="Server2"
    # Start Services search services for SSI
    write-host Start Services search services for SSI
    Start-SPEnterpriseSearchServiceInstance -Identity $SSI
    # 2.Create an Application Pool.
    write-host 2.Create an Application Pool.
    #$AppPool = new-SPServiceApplicationPool -name $SSAName"-AppPool" -account $SVCAcct
    $AppPool = Get-SPServiceApplicationPool -Identity $SearchAppPoolName -ErrorAction SilentlyContinue
    # 3.Create the SearchApplication and set it to a variable
    write-host 3.Create the SearchApplication and set it to a variable
    $SearchApp = New-SPEnterpriseSearchServiceApplication -DatabaseServer $SSADBServer -Name $SSAName -applicationpool $AppPool -databasename $SSADBName
    #4 Create search service application proxy
    write-host 4 Create search service application proxy
    $SSAProxy = new-spenterprisesearchserviceapplicationproxy -name $SSAName"ApplicationProxy" -Uri $SearchApp.Uri.AbsoluteURI
    # 5.Provision Search Admin Component.
    write-host 5.Provision Search Admin Component.
    set-SPenterprisesearchadministrationcomponent -searchapplication $SearchApp -searchserviceinstance $SSI
    # 6.Create a new Crawl Topology.
    write-host 6.Create a new Crawl Topology.
    $CrawlTopo = $SearchApp | New-SPEnterpriseSearchCrawlTopology
    New-SPEnterpriseSearchCrawlComponent -SearchTopology $newTopology -SearchServiceInstance $hostA
    Source:blog.MSDN Author- Russ Maxwell
    Thanks Basva

    Could you please assist me in completing the search service application for
    two server using powershell. Both the servers will be running all the component 
    Hi Basva,
    Do you want to provision two search service applications in single farm?
    Commonly, only one search service application is needed in a farm for Search function.
    Here are articles for detail information about how to provision search service application using powershell:
    http://blogs.msdn.com/b/jjameson/archive/2011/02/28/powershell-script-to-configure-search-in-sharepoint-server-2010.aspx
    http://blogs.msdn.com/b/russmax/archive/2009/10/20/sharepoint-2010-configuring-search-service-application-using-powershell.aspx
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

Maybe you are looking for

  • Tricky sql for report purpose

    Hi all, Please see the example and help me out is there any solution to get below Required output. with t as (select '61527' as cp_Code,'RELEASE SWITCH' as Cp_Des,'88967095' as Part_No,'1800' as List_Price from dual union all select '61527' as cp_Cod

  • Limitations while conected HANA universe to design studio

    Hi All, Previously i have created number of dashboard reports in Design Studio using BEx quires. Recently we moved to HANA database. From HANA we have universe connected to Design studio. Here we are facing some problems. It is not accepting huge dat

  • 999 generation for errors in ISA/GS envelopes

    Hi All, We are testing 999 functionality; 999 is not generated if there is any error in the envelopes(like incorrect Group count). How to enable it? Or do we have to go for TA1 to get this functionality? This is for X12 HIPAA transaction. Thanks, Kat

  • Jump query - basics

    Hi, I am new to jump queries.  There are summary and detailed queries based on jump query on my system.  What do I have to do to go to detailed query in the summary report? RClick on something? For ex: ord----cust 123----ABC 456----XYZ If I want to s

  • My nokia 7230 can't send msg

    Hi can anyone help me out please, it's about my Nokia 7230 i can't recieve message but i can send message... can anyone help