1C

1C Creating InfoBases via RAS

PowerShell script below:

$infobase = "base_name"

$sql_server_host = "sqlhost"
$sql_user_login = "sql_login"
$sql_user_password = "sql_password"

$odin_s_rac = '"C:\Program Files\1cv8\8.3.8.1652\bin\rac.exe"'
# --create-database

$cluster_id = . $odin_s_rac cluster list |
Select -first 1 |
ForEach-object { $_.Trim("cluster                       :") }

. $odin_s_rac infobase `
--cluster=$cluster_id create  `
--name=$infobase `
--dbms=MSSQLServer `
--db-server=$sql_server_host `
--db-name=$infobase `
--db-user=$sql_user_login `
--db-pwd=$sql_user_password `
--scheduled-jobs-deny=on `
--license-distribution=allow `
--locale=ru

$InfoBasePath = "Srvr=`"servername`";Ref=`"$($infobase)`";"

Write-Host $InfoBasePath

Write  $InfoBasePath | clip
Posted by admin in 1C

1C server infobases list view script

The script is below:

$ib_list = @()
$re_SrvInfo                                     =   '-d\s+"([\w\d\:\\\s]+?)"'
$re_Port                                        =   '{[\w\d]{8}-([\w\d]{4}-){3}[\w\d]{12},"*.*?"*,(\d+)'
$re_C1_InfoBase                                 =   '{([\w\d]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12}),"(.*?)",".*?","(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","(.*?DB=.*?DBMS=.+),.,\n{\d,\d{14},\d{14},.*},(\d),.*}'

$C1CommandLine                                  =   Get-WmiObject Win32_Process -Filter "name = 'ragent.exe'" | Select-Object CommandLine
$C1CommandLine                                  |   % {
    if ($_ -match $re_SrvInfo){
        $C1SrvInfoDir                           =   $Matches[1]
        $C1_1cv8wsrv                            =   "$C1SrvInfoDir\1cv8wsrv.lst"
        $C1_1cv8wsrv_content                    =   Get-Content -Path $C1_1cv8wsrv -Encoding UTF8
        foreach($line in $C1_1cv8wsrv_content -match $re_Port){
            if($line -match $re_Port){
                $c1_port_dir                    =   "$C1SrvInfoDir\reg_"+$Matches[2]
                $c1_cluster_content             =   Get-Content -Raw -Path "$c1_port_dir\1CV8Clst.lst"
                $c1_cluster_content = $c1_cluster_content.Replace("`r`n","`n")
                $ibs = $c1_cluster_content | Select-String $re_C1_InfoBase -AllMatches | Foreach {$_.Matches}
                
                # write-host $ibs
                foreach($base in $ibs){
                    write-host $base.GetType() $base.Groups[2]  $base.Groups[1]  $base.Groups[6]  $base.Groups[9]                    
                    $ib_guid = $base.Groups[1]
                    $ib_block_bjob = $base.Groups[9]
                    $ib_name = $base.Groups[2]
                    $ib_dbms = $base.Groups[3]
                    $ib_dbsrv = $base.Groups[4]
                    $ib_dbname = $base.Groups[5]
                    $ib_dbuser = $base.Groups[6]
                                   
                    $ib_list += ([ordered]@{"IB NAME"=$ib_name; "BLOCK BJ"=$ib_block_bjob; "IB GUID"=$ib_guid; "IB DBMS"=$ib_dbms; "IB DB SRV"=$ib_dbsrv; "IB DBNAME"=$ib_dbname; "IB DB USER"=$ib_dbuser})
                }                                   
            }
        }
    }
}

$ib_list = $ib_list | % { New-Object object | Add-Member -NotePropertyMembers $_ -PassThru }

$Result = $ib_list | Out-GridView -PassThru  -Title '1C Server IB List'
Posted by admin in 1C

Create custom service for 1C:Enterprise Server Agent

bat script for agent:

@echo off

set odin_s_version=8.3.16.1296
set port_prefix=16

set service_name="1C:Enterprise Server Agent %odin_s_version%"
set binPathVar="\"C:\Program Files\1cv8\%odin_s_version%\bin\ragent.exe\" -srvc -agent -regport %port_prefix%41 -port %port_prefix%40 -range %port_prefix%60:%port_prefix%91 -d \"C:\1c_srvinfo_custom\%odin_s_version%\" -debug"


sc create %service_name% binPath= %binPathVar% start= auto displayname= %service_name%
sc description %service_name% %service_name%
sc start %service_name%

bat script for ras server

@echo off

set odin_s_version=8.3.16.1814
set port_prefix=16

set service_name="1C:Enterprise Remote Server %odin_s_version%"
set binPathVar="\"C:\Program Files\1cv8\%odin_s_version%\bin\ras.exe\" cluster --service --port=%port_prefix%45 localhost:%port_prefix%40"

sc create %service_name% binPath= %binPathVar% start= auto displayname= %service_name%
sc description %service_name% %service_name%
sc start %service_name%
Posted by admin in 1C