Update 44 files
- /Daily_Backup_review/database_s3_check.ps1 - /Daily_Backup_review/Get-StorageContainerContent.ps1 - /Daily_Backup_review/Global_Checks.ps1 - /Daily_Backup_review/list_table_within_databases.ps1 - /Daily_Backup_review/Start-AzureSQLExport.ps1 - /Daily_Backup_review/Start-BackupCheckBpScus.ps1 - /Daily_Backup_review/Start-BackupCheckBpWeu.ps1 - /Daily_Backup_review/Start-BackupCheckRoserAttachments.ps1 - /Daily_Backup_review/Start-BackupCheckRoserCloud.ps1 - /Daily_Backup_review/Start-BackupCheckTotal.ps1 - /Daily_Backup_review/Start-DatabaseExport.ps1 - /Daily_Backup_review/Start-PointInTimeRestore.ps1 - /Daily_Backup_review/list_databases_within_instances.py - /Daily_Citrix_VDA_and_Server_Utilization_review/Cloudwatch_review/cloudwatch_alarm_ap-southeast-2.json - /Daily_Citrix_VDA_and_Server_Utilization_review/Cloudwatch_review/Cloudwatch_review.ps1 - /Ansible/audit-netscaler-exp.yaml - /Ansible/concurrent-user.yaml - /Ansible/do-something.yaml - /Ansible/hello-world.yaml - /Ansible/p6-log-cleanup.yaml - /Ansible/Roser_DB_backup_one_off.yaml - /Ansible/test-sql.yaml - /Ansible/test-sql-double-creds.yaml - /RoserUsefull/access_bulk_servers.ps1 - /RoserUsefull/access_bulk_servers_cezar.ps1 - /RoserUsefull/Bulk_copy_files.ps1 - /RoserUsefull/Besfort_data.ps1 - /RoserUsefull/check_permissions_bulk_servers.ps1 - /RoserUsefull/Check-p6interface-checksum.ps1 - /RoserUsefull/compare_files.ps1 - /RoserUsefull/connections_parser.ps1 - /RoserUsefull/drop_rds_registry_key.ps1 - /RoserUsefull/EmergencyAccessRemote.ps1 - /RoserUsefull/Keycloak_TestConnection.ps1 - /RoserUsefull/Kickoff_disconnected_users.ps1 - /RoserUsefull/launch_jira.ps1 - /RoserUsefull/launch_jira_gui.ps1 - /RoserUsefull/ownership_taker_anonymized.ps1 - /RoserUsefull/purge_files.ps1 - /RoserUsefull/remove_local_profiles_PowerShell.PS1 - /RoserUsefull/retrieve_attachements.ps1 - /RoserUsefull/Send_patch_multiple_servers.ps1 - /RoserUsefull/Test-RSAAPI-BP.ps1 - /RoserUsefull/Linux_identify_big_files.sh
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
- hosts: all
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: display time
|
||||
ansible.builtin.shell: echo {{ '%Y%m%d' | strftime }}
|
||||
register: today_date
|
||||
|
||||
- name: Set variables current date
|
||||
set_fact:
|
||||
current_date: "{{ today_date.stdout}}"
|
||||
|
||||
- name: Set variables Db name with the date
|
||||
set_fact:
|
||||
DbNameWithDate: "{{DBname+current_date}}"
|
||||
|
||||
- name: Set variables ARN
|
||||
set_fact:
|
||||
Arn_generated: "{{'arn:aws:s3:::'+S3Bucket+'/'+DBInstancename+'/'+current_date+'/'+DbNameWithDate+additional_comment+'.bak'}}"
|
||||
|
||||
- name: perform the query
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
script: |
|
||||
USE [MASTER]
|
||||
DECLARE @arn varchar(MAX) = '{{Arn_generated}}'
|
||||
exec msdb.dbo.rds_backup_database @source_db_name='{{DBname}}', @s3_arn_to_backup_to=@arn ,@overwrite_s3_backup_file=1;
|
||||
register: db_output
|
||||
|
||||
- name: Set task ID
|
||||
set_fact:
|
||||
Task_ID: "{{db_output.query_results[0][0][0][0]}}"
|
||||
#testing
|
||||
#Task_ID: "9124"
|
||||
|
||||
|
||||
- name: Display task ID
|
||||
debug: var=Task_ID
|
||||
|
||||
- name: Check the status of the backup
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
script: |
|
||||
USE [MASTER]
|
||||
exec msdb.dbo.rds_task_status @task_id='{{Task_ID}}'
|
||||
register: db_backup_output
|
||||
until: "'SUCCESS' in db_backup_output.query_results[0][0][0][5] or 'ERROR' in db_backup_output.query_results[0][0][0][5]"
|
||||
retries: 10
|
||||
delay: 60
|
||||
failed_when: "'ERROR' in db_backup_output.query_results[0][0][0][5]"
|
||||
|
||||
|
||||
- name: Display Status of the task
|
||||
debug: var=db_backup_output.query_results[0][0][0][5]
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- hosts: all
|
||||
gather_facts: no
|
||||
vars:
|
||||
ansible_remote_tmp: /tmp
|
||||
ssh_executable: shell
|
||||
tasks:
|
||||
- name: Enter shell
|
||||
shell: ls
|
||||
|
||||
- name: Execute aws-cost script
|
||||
shell: cat /nsconfig/license/FID_449a0c5a_a0c5_4bdb_98e1_200eff40afc7.lic | grep -oE '\.*[0-9]+\-(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\-[0-9][0-9][0-9][0-9]'
|
||||
@@ -0,0 +1,56 @@
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Concurrent User
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
db: "{{ db_name }}"
|
||||
script: |
|
||||
use {{ db_name }}
|
||||
DECLARE @start Datetime = '{{ begin_date }}';
|
||||
DECLARE @end Datetime = '{{ end_date }}';
|
||||
WITH RankedDays AS (
|
||||
SELECT
|
||||
login_day,
|
||||
column_{{ month }}{{ year }}_concurrent_user_count,
|
||||
ROW_NUMBER() OVER (PARTITION BY MONTH(login_day) ORDER BY column_{{ month }}{{ year }}_concurrent_user_count DESC) AS rn
|
||||
FROM
|
||||
(
|
||||
select login_day, max(column_{{ month }}{{ year }}_concurrent_user_count) column_{{ month }}{{ year }}_concurrent_user_count from (
|
||||
SELECT
|
||||
DISTINCT CAST(ul_main.logindate AS DATE) AS login_day,
|
||||
( SELECT
|
||||
COUNT(DISTINCT CHECKSUM(ul_sub.fk_userid, ul_sub.createcomputer))
|
||||
FROM
|
||||
tblUserLogin ul_sub
|
||||
INNER JOIN tblApplication a ON a.pk_applicationid = ul_sub.fk_applicationid
|
||||
WHERE
|
||||
a.enumvalue IN (2, 3, 4, 5, 7, 11, 13, 15, 6, 9, 18, 10) --no rosercatalog!
|
||||
AND ul_sub.logindate <= ul_main.logindate
|
||||
AND (
|
||||
CASE
|
||||
WHEN lastheartbeat < logoutdate
|
||||
THEN lastheartbeat
|
||||
ELSE logoutdate
|
||||
END
|
||||
) >= ul_main.logindate
|
||||
) AS column_{{ month }}{{ year }}_concurrent_user_count
|
||||
FROM
|
||||
tblUserLogin ul_main
|
||||
WHERE
|
||||
ul_main.logindate >= @start
|
||||
AND ul_main.logindate < @end
|
||||
) max_of_each_month group by login_day ) sub_query
|
||||
WHERE login_day LIKE '{{ year }}%'
|
||||
)
|
||||
SELECT
|
||||
login_day,
|
||||
column_{{ month }}{{ year }}_concurrent_user_count
|
||||
FROM
|
||||
RankedDays
|
||||
WHERE
|
||||
rn <= 1
|
||||
ORDER BY
|
||||
MONTH(login_day),
|
||||
column_{{ month }}{{ year }}_concurrent_user_count DESC;
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- hosts: all
|
||||
gather_facts: no
|
||||
vars:
|
||||
ansible_remote_tmp: /tmp
|
||||
ssh_executable: shell
|
||||
tasks:
|
||||
- name: Enter shell
|
||||
shell: ls
|
||||
|
||||
- name: Execute aws-cost script
|
||||
shell: cat /nsconfig/license/FID_449a0c5a_a0c5_4bdb_98e1_200eff40afc7.lic | grep -oE '\.*[0-9]+\-(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\-[0-9][0-9][0-9][0-9]'
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- hosts: VDA-R7Y95
|
||||
tasks:
|
||||
- name: Run basic PowerShell script
|
||||
ansible.windows.win_powershell:
|
||||
script: |
|
||||
echo "Hello World"
|
||||
write-output "Hiya, AWx" | Out-File c:\temp\my-first-awx.txt
|
||||
@@ -0,0 +1,33 @@
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Cleanup P6 logs
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
db: "{{ db_name }}"
|
||||
script: |
|
||||
use {{ db_name }}
|
||||
IF EXISTS (select p.pk_p6sessionid, p.createdate, p.modifydate, h.modifydate, getdate() from rsy.tblP6Session p join rsy.tblP6SessionHeartbeat h on p.pk_p6sessionid = h.fk_p6sessionid where p.createdate > DATEADD(HOUR, -6, GETDATE()) and h.modifydate > DATEADD(HOUR, -2, GETDATE()))
|
||||
BEGIN
|
||||
SELECT 'Possible active Sessions';
|
||||
select p.pk_p6sessionid, p.createdate, p.modifydate, h.modifydate, getdate() from rsy.tblP6Session p
|
||||
join rsy.tblP6SessionHeartbeat h on p.pk_p6sessionid = h.fk_p6sessionid
|
||||
where p.createdate > DATEADD(HOUR, -6, GETDATE()) and h.modifydate > DATEADD(HOUR, -2, GETDATE())
|
||||
END ELSE
|
||||
BEGIN
|
||||
SELECT 'do cleanup'
|
||||
BEGIN TRAN
|
||||
SELECT TOP (1) 1 FROM [rsy].[tblP6Session] WITH (TABLOCKX);
|
||||
truncate table [rsy].[tblP6SessionHeartbeat];
|
||||
truncate table [rsy].[tblP6SessionLog];
|
||||
truncate table [rsy].[tblP6SessionMilestone];
|
||||
truncate table [rsy].[tblP6SessionPlancard];
|
||||
truncate table [rsy].[tblP6SessionRelation];
|
||||
alter table [rsy].[tblP6Session] disable trigger all;
|
||||
delete from [rsy].[tblP6Session];
|
||||
alter table [rsy].[tblP6Session] enable trigger all;
|
||||
COMMIT TRAN;
|
||||
END
|
||||
register: db_output
|
||||
- debug: var=db_output
|
||||
@@ -0,0 +1,12 @@
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Test Connectivity
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
script: |
|
||||
USE {{ db_name }}
|
||||
SELECT * FROM dbo.tblsetting;
|
||||
register: db_output
|
||||
- debug: var=db_output
|
||||
@@ -0,0 +1,13 @@
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Test Connectivity
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
db: "{{ db_name }}"
|
||||
script: |
|
||||
USE {{ db_name }}
|
||||
SELECT * FROM dbo.tblsetting;
|
||||
register: db_output
|
||||
- debug: var=db_output
|
||||
@@ -0,0 +1,51 @@
|
||||
Param(
|
||||
$SubscriptionID,
|
||||
$ResourceGroupName,
|
||||
$StorageAccountName,
|
||||
$StorageContainerName,
|
||||
$Prefix='',
|
||||
[switch]$NonInteractive
|
||||
)
|
||||
|
||||
Login-AzAccount | Out-Null
|
||||
|
||||
if(-not $SubscriptionID) {
|
||||
$Subscription = Get-AzSubscription | Out-Gridview -passthru
|
||||
} else {
|
||||
$Subscription = Get-AzSubscription -SubscriptionId $SubscriptionID
|
||||
}
|
||||
Select-AzSubscription -Subscription $Subscription.SubscriptionId | Out-Null
|
||||
|
||||
if(-not $ResourceGroupName) {
|
||||
$ResourceGroup = Get-AzResourceGroup | Out-Gridview -passthru
|
||||
} else {
|
||||
$ResourceGroup = Get-AzResourceGroup -ResourceGroupName $ResourceGroupName
|
||||
}
|
||||
|
||||
if(-not $StorageAccountName ) {
|
||||
$StorageAccount = Get-AzStorageAccount -ResourceGroupName $ResourceGroup.ResourceGroupName | Out-GridView -PassThru
|
||||
} else {
|
||||
$StorageAccount = Get-AzStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName
|
||||
}
|
||||
|
||||
$StorageAccountKey = Get-AzStorageAccountKey -Name $Storageaccount.StorageAccountName -ResourceGroupName $ResourceGroup.ResourceGroupName
|
||||
$Context = New-AzStorageContext -StorageAccountName $StorageAccount.StorageAccountName -StorageAccountKey $StorageAccountKey[0].Value
|
||||
|
||||
if(-not $StorageContainerName) {
|
||||
$StorageContainer = Get-AzStorageContainer -Context $Context | Out-GridView -PassThru
|
||||
} else {
|
||||
$StorageContainer = Get-AzStorageContainer -Context $Context -Name $StorageContainerName
|
||||
}
|
||||
|
||||
$DRY = @"
|
||||
`$Parameters = @{
|
||||
subscription = '$($Subscription.SubscriptionID)'
|
||||
ResourceGroupName = '$($ResourceGroup.ResourceGroupName)'
|
||||
StorageAccountName = '$($StorageAccount.StorageAccountName)'
|
||||
StorageContainerName = '$($StorageContainer.Name)'
|
||||
}
|
||||
"@
|
||||
|
||||
Write-Verbose $DRY
|
||||
|
||||
Get-AzStorageBlob -Context $Context -Container $StorageContainer.Name -Prefix $Prefix
|
||||
@@ -0,0 +1,139 @@
|
||||
|
||||
begin {
|
||||
$global_parameters = @(
|
||||
@{
|
||||
name = 'Bp Scus'
|
||||
Cloud_provider = 'Azure'
|
||||
subscription = 'ac782c49-b833-4ca1-b632-5eb85281cc26'
|
||||
ResourceGroupName = 'rg-BP-shared-scus01'
|
||||
StorageAccountName = 'roserbpsqlbackupscus'
|
||||
StorageContainerName = 'backupcontainer'
|
||||
},
|
||||
@{
|
||||
name = 'Bp Weu'
|
||||
Cloud_provider = 'Azure'
|
||||
subscription = 'ac782c49-b833-4ca1-b632-5eb85281cc26'
|
||||
ResourceGroupName = 'rg-BP-shared-weu01'
|
||||
StorageAccountName = 'roserbpsqlbackupweu'
|
||||
StorageContainerName = 'backupcontainer'
|
||||
},
|
||||
@{
|
||||
name = 'Total'
|
||||
Cloud_provider = 'Azure'
|
||||
subscription = '40c3c7b3-1bd7-446b-b6a3-45ac84246fb9'
|
||||
ResourceGroupName = 'rg-Tot-resources-weu01'
|
||||
StorageAccountName = 'rosertotalbackup'
|
||||
StorageContainerName = 'backupcontainer'
|
||||
},
|
||||
@{
|
||||
name = 'RoserCloud'
|
||||
Cloud_provider = 'AWS'
|
||||
subscription = ''
|
||||
ResourceGroupName = 'operations_west-europe'
|
||||
StorageAccountName = 'rosercloud-sql-backup'
|
||||
StorageContainerName = 'rosercloud-rpsql02'
|
||||
}
|
||||
)
|
||||
|
||||
#date variables
|
||||
$Today_date = Get-Date -Format "yyyyMMdd"
|
||||
$Yesterday_date = (get-Date).AddDays(-1).ToString('yyyyMMdd')
|
||||
#clear the screen
|
||||
cls
|
||||
|
||||
#login into AZURE
|
||||
#Login-AzAccount | Out-Null
|
||||
Connect-AzAccount -TenantId 419c9123-a9c1-4908-9c5f-c2f34cc15973 | Out-Null
|
||||
}
|
||||
process {
|
||||
For ($occurences = 0; $occurences -lt $global_parameters.count; $occurences++) {
|
||||
#For ($occurences = 1; $occurences -lt 3; $occurences++) {
|
||||
if ($global_parameters[$occurences].Cloud_provider -eq "Azure") {
|
||||
Write-Host $global_parameters[$occurences].name -ForegroundColor Green
|
||||
$SubscriptionID = $global_parameters[$occurences].subscription
|
||||
$ResourceGroupName = $global_parameters[$occurences].ResourceGroupName
|
||||
$StorageAccountName = $global_parameters[$occurences].StorageAccountName
|
||||
$StorageContainerName = $global_parameters[$occurences].StorageContainerName
|
||||
$Blob = '*.bak'
|
||||
|
||||
|
||||
|
||||
#verification of SubscriptionID and assign it if required
|
||||
if (-not $SubscriptionID) {
|
||||
$Subscription = Get-AzSubscription | Out-Gridview -passthru
|
||||
}
|
||||
else {
|
||||
$Subscription = Get-AzSubscription -SubscriptionId $SubscriptionID
|
||||
}
|
||||
Select-AzSubscription -Subscription $Subscription.SubscriptionId | Out-Null
|
||||
|
||||
|
||||
#verification of ResourceGroupName and assign it if required
|
||||
if (-not $ResourceGroupName) {
|
||||
$ResourceGroup = Get-AzResourceGroup | Out-Gridview -passthru
|
||||
}
|
||||
else {
|
||||
$ResourceGroup = Get-AzResourceGroup -ResourceGroupName $ResourceGroupName
|
||||
}
|
||||
|
||||
|
||||
#verification of StorageAccountName and assign it if required
|
||||
if (-not $StorageAccountName ) {
|
||||
$StorageAccount = Get-AzStorageAccount -ResourceGroupName $ResourceGroup.ResourceGroupName | Out-GridView -PassThru
|
||||
}
|
||||
else {
|
||||
$StorageAccount = Get-AzStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName
|
||||
}
|
||||
$StorageAccountKey = Get-AzStorageAccountKey -Name $Storageaccount.StorageAccountName -ResourceGroupName $ResourceGroup.ResourceGroupName
|
||||
$Context = New-AzStorageContext -StorageAccountName $StorageAccount.StorageAccountName -StorageAccountKey $StorageAccountKey[0].Value
|
||||
|
||||
|
||||
#verification of StorageContainerName and assign it if required
|
||||
if (-not $StorageContainerName) {
|
||||
$StorageContainer = Get-AzStorageContainer -Context $Context | Out-GridView -PassThru
|
||||
}
|
||||
else {
|
||||
$StorageContainer = Get-AzStorageContainer -Context $Context -Name $StorageContainerName
|
||||
}
|
||||
|
||||
|
||||
|
||||
#start the action of listing
|
||||
$ContainerContent = Get-AzStorageBlob -Context $Context -Container $StorageContainer.Name -Blob $blob
|
||||
#display ContainerContent
|
||||
$ContainerContent | Out-GridView -Title $global_parameters[$occurences].name
|
||||
|
||||
#determine number of saves for today and yesterday and display them
|
||||
$result_today = $ContainerContent | Where-object { ($_.LastModified.DateTime -gt (Get-Date).Date) }
|
||||
$result_yesterday = $ContainerContent | Where-object { ($_.LastModified.DateTime -gt (Get-Date).AddDays(-1).Date) -and ($_.LastModified.DateTime -lt (Get-Date).Date) }
|
||||
|
||||
|
||||
Write-Host "number of saves today: "$result_today.count
|
||||
Write-Host "number of saves yesterday: "$result_yesterday.count
|
||||
}
|
||||
elseif ($global_parameters[$occurences].Cloud_provider -eq "AWS") {
|
||||
Write-Host $global_parameters[$occurences].name -ForegroundColor Green
|
||||
function Number_backups_s3 {
|
||||
param(
|
||||
[Parameter (Mandatory = $true)] [String]$string_day,
|
||||
[Parameter (Mandatory = $true)] [int]$date_wanted
|
||||
)
|
||||
$prefix = $global_parameters[$occurences].StorageContainerName
|
||||
$s3_result = aws s3api list-objects --bucket $global_parameters[$occurences].StorageAccountName --prefix "$prefix/$date_wanted/"
|
||||
$s3_result_converted_from_json = $s3_result | ConvertFrom-Json
|
||||
|
||||
Write-host "number of saves"$string_day$($s3_result_converted_from_json.Contents.count)
|
||||
|
||||
|
||||
}
|
||||
Number_backups_s3 -string_day "today: " -date_wanted $Today_date
|
||||
Number_backups_s3 -string_day "Yesterday: " -date_wanted $Yesterday_date
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
end {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
$subscription = '40c3c7b3-1bd7-446b-b6a3-45ac84246fb9'
|
||||
$ResourceGroupName = 'rg-Tot-resources-weu01'
|
||||
$StorageAccountName = 'rosertotalbackup'
|
||||
$StorageContainerName = 'backupcontainer'
|
||||
|
||||
$DatabaseName = 'p_rc_anv'
|
||||
|
||||
|
||||
$exportRequest = New-AzSqlDatabaseExport -ResourceGroupName $ResourceGroupName -ServerName $ServerName `
|
||||
-DatabaseName $DatabaseName -StorageKeytype $StorageKeytype -StorageKey $StorageKey -StorageUri $BacpacUri `
|
||||
-AdministratorLogin $creds.UserName -AdministratorLoginPassword $creds.Password
|
||||
@@ -0,0 +1,9 @@
|
||||
$Parameters = @{
|
||||
subscription = 'ac782c49-b833-4ca1-b632-5eb85281cc26'
|
||||
ResourceGroupName = 'rg-BP-shared-scus01'
|
||||
StorageAccountName = 'roserbpsqlbackupscus'
|
||||
StorageContainerName = 'backupcontainer'
|
||||
}
|
||||
|
||||
$ContainerContent = ./Get-StorageContainerContent.ps1 @Parameters | sort-object -Property LastModified -Descending
|
||||
$ContainerContent | Where-object { $_.Name -like '*.bak'} | Out-GridView
|
||||
@@ -0,0 +1,9 @@
|
||||
$Parameters = @{
|
||||
subscription = 'ac782c49-b833-4ca1-b632-5eb85281cc26'
|
||||
ResourceGroupName = 'rg-BP-shared-weu01'
|
||||
StorageAccountName = 'roserbpsqlbackupweu'
|
||||
StorageContainerName = 'backupcontainer'
|
||||
}
|
||||
|
||||
$ContainerContent = ./Get-StorageContainerContent.ps1 @Parameters | sort-object -Property LastModified -Descending
|
||||
$ContainerContent | Where-object { $_.Name -like '*.bak'} | Out-GridView
|
||||
@@ -0,0 +1,11 @@
|
||||
$Parameters = @{
|
||||
subscription = '40c3c7b3-1bd7-446b-b6a3-45ac84246fb9'
|
||||
ResourceGroupName = 'operations_west-europe'
|
||||
StorageAccountName = 'roserdataexchange'
|
||||
StorageContainerName = 'appdocs'
|
||||
}
|
||||
|
||||
|
||||
$ContainerContent = ./Get-StorageContainerContent.ps1 @Parameters -Prefix '_appdocs_log'
|
||||
$ViewContent = $ContainerContent | Sort-Object -Property LastModified -Descending | Select-Object -First 1 | Get-AzStorageBlobContent -Destination $env:TEMP
|
||||
notepad $ENV:TEMP\$($ViewContent.name)
|
||||
@@ -0,0 +1,14 @@
|
||||
$Parameters = @{
|
||||
subscription = '40c3c7b3-1bd7-446b-b6a3-45ac84246fb9'
|
||||
ResourceGroupName = 'operations_west-europe'
|
||||
StorageAccountName = 'roserdataexchange'
|
||||
StorageContainerName = 'backups'
|
||||
}
|
||||
|
||||
$date = (get-date).AddDays(-1)
|
||||
$Prefix = "{0}{1:D2}{2:D2}" -f $date.Year, $date.Month, $date.Day
|
||||
|
||||
|
||||
|
||||
$ContainerContent = ./Get-StorageContainerContent.ps1 @Parameters -Prefix $Prefix
|
||||
$ContainerContent | Where-object { $_.Name -like '*.bak'} | Out-GridView
|
||||
@@ -0,0 +1,20 @@
|
||||
$Parameters = @{
|
||||
subscription = '40c3c7b3-1bd7-446b-b6a3-45ac84246fb9'
|
||||
ResourceGroupName = 'rg-Tot-resources-weu01'
|
||||
StorageAccountName = 'rosertotalbackup'
|
||||
StorageContainerName = 'backupcontainer'
|
||||
}
|
||||
$ContainerContent = ./Get-StorageContainerContent.ps1 @Parameters | sort-object -Property LastModified -Descending
|
||||
$ContainerContent | Where-object { $_.Name -like '*.bak'} | Out-GridView
|
||||
|
||||
|
||||
$ParamAzSql = @{
|
||||
ResourceGroupName = $Parameters.ResourceGroupName
|
||||
}
|
||||
|
||||
'tot-managed-sql-production','tot-2020-sql-production' | ForEach-Object {
|
||||
$ParamAzSql.InstanceName = $_
|
||||
Get-AzSqlInstanceDatabase @ParamAzSql | Get-AzSqlInstanceDatabaseBackupShortTermRetentionPolicy
|
||||
} | Out-GridView
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Export Azure Managed SQL Database to bacpac file
|
||||
.DESCRIPTION
|
||||
Uses sqlpackage.exe to export a database.
|
||||
#>
|
||||
|
||||
cd 'C:\Program Files\Microsoft SQL Server\150\DAC\bin'
|
||||
|
||||
$DBACredential = Get-Credential -UserName pgadmin -Message 'Backup Credential: Total SQL DBA (Azure) in Lastpass'
|
||||
$Database=''
|
||||
|
||||
if(-not $Database) {
|
||||
Write-Error "Please configure database"
|
||||
}
|
||||
|
||||
$Server='tcp:tot-2020-sql-acceptance.03ddfc49f186.database.windows.net,1433'
|
||||
|
||||
#sqlpackage.exe /Action:Export /ssn:tcp:MyOwnServer.database.windows.net,1433 /sdn:AdventureWorks /su:AdminUser /sp:AdminPassword1 /tf:C:\Temp\AW.bacpac /p:Storage=File
|
||||
./sqlpackage.exe /Action:Export /ssn:$server /sdn:$database /su:pgadmin /sp:$($DBACredential.GetNetworkCredential().Password) /tf:F:\export\$($Database).bacpac /p:Storage=File
|
||||
@@ -0,0 +1,85 @@
|
||||
Param(
|
||||
$SubscriptionID,
|
||||
$ResourceGroupName,
|
||||
$SourceInstanceName,
|
||||
$SourceDatabaseName,
|
||||
$DestinationInstanceName,
|
||||
$DestinationDatabaseName,
|
||||
$PointInTime,
|
||||
[switch]$NonInteractive
|
||||
)
|
||||
|
||||
|
||||
Write-Verbose "- $($PSBoundParameters | ConvertTo-Json)"
|
||||
|
||||
Login-AzAccount
|
||||
|
||||
if(-not $SubscriptionID) {
|
||||
$Subscription = Get-AzSubscription | Out-Gridview -passthru # Select your subscription
|
||||
} else {
|
||||
$Subscription = Get-AzSubscription -SubscriptionId $SubscriptionID
|
||||
}
|
||||
Select-AzSubscription -Subscription $Subscription.SubscriptionId
|
||||
|
||||
if(-not $ResourceGroupName) {
|
||||
$ResourceGroup = Get-AzResourceGroup | Out-Gridview -passthru # Select your resource group
|
||||
} else {
|
||||
$ResourceGroup = Get-AzResourceGroup -ResourceGroupName $ResourceGroupName
|
||||
}
|
||||
|
||||
if(-not $SourceInstanceName) {
|
||||
$SourceInstance = Get-AzSqlInstance | Out-Gridview -Passthru # Select the source instance for the restore
|
||||
} else {
|
||||
$SourceInstance = Get-AzSqlInstance -Name $SourceInstanceName
|
||||
}
|
||||
|
||||
if(-not $DestinationInstanceName) {
|
||||
$DestinationInstance = Get-AzSqlInstance | Out-GridView -PassThru # Select the Target instance for the restore
|
||||
} else {
|
||||
$DestinationInstance = Get-AzSqlInstance -Name $DestinationInstanceName
|
||||
}
|
||||
|
||||
if(-not $SourceDatabaseName) {
|
||||
$SourceDatabase = Get-AzSqlInstanceDatabase -InstanceName $SourceInstance.ManagedInstanceName -ResourceGroupName $ResourceGroup.ResourceGroupName | Out-GridView -PassThru # Select Database to restore
|
||||
} else {
|
||||
$SourceDatabase = Get-AzSqlInstanceDatabase -InstanceName $SourceInstance.ManagedInstanceName -Name $SourceDatabaseName -ResourceGroupName $ResourceGroup.ResourceGroupName
|
||||
}
|
||||
|
||||
if(-not $DestinationDatabaseName) {
|
||||
$DestinationDatabaseName = read-host -Prompt 'Destination DB name'
|
||||
}
|
||||
|
||||
if(-not $PointInTime) {
|
||||
$PointInTime = Get-Date
|
||||
}
|
||||
|
||||
|
||||
$ParamRestoreAzSqlinstanceDatabase = @{
|
||||
FromPointInTimeBackup = $true
|
||||
InstanceName = $SourceInstance.ManagedInstanceName
|
||||
Name = $SourceDatabase.Name
|
||||
ResourceGroupName = $ResourceGroup.ResourceGroupName
|
||||
PointInTime = $PointInTime
|
||||
TargetInstanceDatabaseName = $DestinationDatabaseName
|
||||
TargetResourceGroupName = $ResourceGroup.ResourceGroupName
|
||||
TargetInstanceName = $DestinationInstance.ManagedInstanceName
|
||||
}
|
||||
|
||||
Write-Verbose @"
|
||||
@Param = @{
|
||||
`$SubscriptionID = '$($Subscription.SubscriptionID)'
|
||||
`$ResourceGroupName = '$($ResourceGroup.ResourceGroupName)'
|
||||
`$SourceInstanceName = '$($SourceInstance.ManagedInstanceName)'
|
||||
`$SourceDatabaseName = '$($SourceDatabase.Name)'
|
||||
`$DestinationInstanceName = '$($DestinationInstance.ManagedInstanceName)'
|
||||
`$DestinationDatabaseName = '$($DestinationDatabaseName)'
|
||||
}
|
||||
"@
|
||||
|
||||
|
||||
if(-not $NonInteractive) {
|
||||
write-warning "$($ParamRestoreAzSqlinstanceDatabase | ConvertTo-JSon)"
|
||||
Write-Warning "Continue with Restore?" -WarningAction Inquire
|
||||
}
|
||||
|
||||
Restore-AzSqlinstanceDatabase @ParamRestoreAzSqlInstanceDatabase
|
||||
@@ -0,0 +1,27 @@
|
||||
#$RDS_instances = aws rds describe-db-instances| ConvertFrom-Json
|
||||
#$RDS_instances = aws rds describe-db-instances --db-instance-identifier rosermigration| ConvertFrom-Json
|
||||
$RDS_instances = aws rds describe-db-instance-automated-backups | ConvertFrom-Json
|
||||
|
||||
#date variables
|
||||
$Today_date = Get-Date -Format "yyyyMMdd"
|
||||
$Yesterday_date = (get-Date).AddDays(-1).ToString('yyyyMMdd')
|
||||
|
||||
foreach ($DBInstance in $RDS_instances.DBInstanceAutomatedBackups) {
|
||||
Write-Host "DB : "$DBInstance.DBInstanceIdentifier -ForegroundColor Green
|
||||
function Number_backups_s3 {
|
||||
param(
|
||||
[Parameter (Mandatory = $true)] [String]$string_day,
|
||||
[Parameter (Mandatory = $true)] [int]$date_wanted
|
||||
)
|
||||
$prefix = $DBInstance.DBInstanceIdentifier
|
||||
#$s3_result = aws s3api list-objects --bucket rosercloud-sql-backup --prefix "$prefix/$date_wanted/"
|
||||
$s3_result = aws s3api list-objects --bucket rosercloud-sql-backup --query "Contents[?contains(Key, ``$prefix/$Today_date``) == ``true``]"| ConvertFrom-Json
|
||||
#$s3_result_converted_from_json = $s3_result
|
||||
|
||||
Write-host "number of saves"$string_day$($s3_result.Contents.count)
|
||||
|
||||
|
||||
}
|
||||
Number_backups_s3 -string_day "today: " -date_wanted $Today_date
|
||||
Number_backups_s3 -string_day "Yesterday: " -date_wanted $Yesterday_date
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
"""
|
||||
Connects to a SQL database using pyodbc
|
||||
"""
|
||||
import pyodbc
|
||||
from os import path
|
||||
import json
|
||||
|
||||
SERVER = 'tot-2020-sql-acceptance.privatelink.03ddfc49f186.database.windows.net'
|
||||
DATABASE = 'dba_admin'
|
||||
USERNAME = 'pgadmin'
|
||||
PASSWORD = '6^_przWQ$?Ve7,n9'
|
||||
|
||||
|
||||
filename = 'database_description.json'
|
||||
|
||||
connectionString = f'DRIVER={{ODBC Driver 17 for SQL Server}};SERVER={SERVER};DATABASE={DATABASE};UID={USERNAME};PWD={PASSWORD}'
|
||||
|
||||
conn = pyodbc.connect(connectionString)
|
||||
|
||||
Exclude_databases=["master","tempdb","model","msdb"]
|
||||
|
||||
SQL_QUERY = """
|
||||
SELECT name
|
||||
FROM sys.databases;
|
||||
"""
|
||||
|
||||
list_database_name = []
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(SQL_QUERY)
|
||||
|
||||
records = cursor.fetchall()
|
||||
for r in records:
|
||||
if not(Exclude_databases.count(r[0])):
|
||||
print(r[0])
|
||||
dict_database_name={'Name':r[0]}
|
||||
list_database_name.append(dict_database_name)
|
||||
|
||||
dict_global={"Images": list_database_name}
|
||||
# Write to File
|
||||
with open(filename, 'w') as json_file:
|
||||
json.dump(dict_global, json_file, indent=4)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
$AttachmentPath = "C:\Users\cvoicu\Desktop\"
|
||||
|
||||
$QueryFmta= "SELECT name FROM sys.databases where name like 'coconsole_%' and name != 'coconsole_api_database'"
|
||||
|
||||
$coconsole_db= Invoke-Sqlcmd -ServerInstance sql1 -Database 'master' -Query $QueryFmta
|
||||
|
||||
foreach( $database in $coconsole_db ) {
|
||||
write-host $database.name
|
||||
$QueryFmt= "select * from S_updates"
|
||||
|
||||
$db= $database.name
|
||||
|
||||
Invoke-Sqlcmd -ServerInstance sql1 -Database $db -Query $QueryFmt | Export-CSV $AttachmentPath\$db.csv
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#generate the array
|
||||
$data_array_instances = @()
|
||||
|
||||
|
||||
#get all the regions available
|
||||
#remove "--region-names ap-southeast-2" if you want to use all the regions
|
||||
$command_AWS_regions = aws ec2 describe-regions --region-names ap-southeast-2 | ConvertFrom-Json
|
||||
|
||||
foreach ($region in $command_AWS_regions.Regions) {
|
||||
Write-Host "Region used : "$region.RegionName
|
||||
|
||||
$command_AWS = aws ec2 describe-instances --output json --region $region.RegionName | ConvertFrom-Json
|
||||
|
||||
|
||||
#$command_AWS = aws cloudwatch describe-alarms --output json --region ap-southeast-2 | ConvertFrom-Json
|
||||
$command_AWS = aws cloudwatch describe-alarms --output json --region $region.RegionName | ConvertFrom-Json
|
||||
|
||||
|
||||
foreach ( $MetricAlarm in $command_AWS.MetricAlarms ) {
|
||||
|
||||
|
||||
|
||||
$data_array_instances_loop = @(
|
||||
[pscustomobject]@{
|
||||
Name = $MetricAlarm.AlarmName;
|
||||
AlarmDescription = $MetricAlarm.AlarmDescription;
|
||||
StateValue = $MetricAlarm.StateValue;
|
||||
State = $MetricAlarm.Instances.State.Name;
|
||||
Region = $region.RegionName
|
||||
}
|
||||
)
|
||||
$data_array_instances += $data_array_instances_loop
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$data_array_instances | sort-object -Property StateValue -Descending | Out-GridView -title "aws cloudwatch describe-alarms".ToUpper()
|
||||
|
||||
$data_array_instances | Export-Csv -Path $PSScriptRoot\Cloudwatch_review_generated_on_$(Get-Date -Format "yyyy-MM-dd").csv -NoTypeInformation
|
||||
|
||||
+3497
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
|
||||
257330426:100030334880655:Precious:Anderson:female:::::1/1/0001 12:00:00 AM::
|
||||
12257330428:23401637:Michael:Scott:male:New Orleans, Louisiana:::MPATH:2/18/2019 12:00:00 AM:michaelscottnow@gmail.com:
|
||||
12257330435:100000056357274:Byron:Stewart::::::2/2/2019 12:00:00 AM::
|
||||
12257330442:100006427414396:Bw:Bezzy:male:Baton Rouge, Louisiana:Baton Rouge, Louisiana:In a relationship:Get Money Group:2/18/2019 12:00:00 AM::
|
||||
12257330443:100000128437045:Deon:Abram:female:::::2/7/2019 12:00:00 AM::
|
||||
12257330444:100004509129746:Tracy:Taylor:female:Baton Rouge, Louisiana:Napoleonville, Louisiana::Amelia Belle Casino:1/1/0001 12:00:00 AM::
|
||||
12257330451:100000886175617:Phyllis:Arnold:female::::McDonald's:7/24/2014 12:00:00 AM::
|
||||
12257330452:100033201966803:Synia:Trosclair:male:::::1/1/0001 12:00:00 AM::
|
||||
12257330459:100005763072394:Og:Ynwr:male:Baton Rouge, Louisiana::::1/31/2018 12:00:00 AM::
|
||||
12257330461:100025642684110:Marvin:Johnson:male:::::7/11/2018 12:00:00 AM::
|
||||
12257330463:100002187119260:Charles:Walker:male:::::11/17/2017 12:00:00 AM::
|
||||
12257330466:100000526863925:Willie:Adams:male:Baton Rouge, Louisiana:Baton Rouge, Louisiana:In a relationship:U.S. Marine Corps:12/29/2018 12:00:00 AM::
|
||||
12257330469:100010056549366:Dwayne:Knighten:female:::::1/1/0001 12:00:00 AM::
|
||||
12257330474:100002586004515:Briian:Johnson:male::New Orleans, Louisiana:::6/3/2012 12:00:00 AM::
|
||||
12257330477:100011329301982:Auntree:Brown:female:::::4/10/2017 12:00:00 AM::
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
$DebugPreference = "continue"
|
||||
$Exclude = 'Account-IT','p6integrationapi','p6integrationapi_1','Primavera P6'
|
||||
$Executionenvironment = 'production'
|
||||
|
||||
$V21_12_pro_jar_sites = 'Donges','portarthur'
|
||||
|
||||
$sites = Get-ChildItem "C:\roserapps\" -Exclude $Exclude
|
||||
$sites | ForEach-Object {
|
||||
Write-debug $psitem.name
|
||||
$fullName = $psitem.name
|
||||
|
||||
if($Executionenvironment -eq 'production'){
|
||||
$JarFile = 'V17.12.pro.Azure.jar'
|
||||
if($V21_12_pro_jar_sites -contains $fullName ){
|
||||
$JarFile = 'V21.12.pro.jar'
|
||||
}
|
||||
|
||||
}else{
|
||||
$JarFile = 'V21.12.pro.jar'
|
||||
}
|
||||
Write-Host $JarFile -ForegroundColor green
|
||||
certutil -hashfile "C:\roserapps\$fullName\rosersuite\P6 interface\$JarFile" SHA1
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
$s = New-PSSession -ComputerName RPVDA03 -Credential pgeeraert
|
||||
|
||||
Invoke-Command -Session $s -ScriptBlock { Get-Culture }
|
||||
|
||||
Invoke-Command -Session $s -ScriptBlock { hostname }
|
||||
|
||||
#check services
|
||||
Invoke-Command -Session $s -ScriptBlock { get-service}
|
||||
|
||||
#check rdp services
|
||||
Invoke-Command -Session $s -ScriptBlock { get-service TermService }
|
||||
#check rdp services 's dependants
|
||||
Invoke-Command -Session $s -ScriptBlock { get-service TermService -DependentServices }
|
||||
#restrat them
|
||||
Invoke-Command -Session $s -ScriptBlock { Restart-service UmRdpService }
|
||||
Invoke-Command -Session $s -ScriptBlock { Restart-service ServicesManager }
|
||||
Invoke-Command -Session $s -ScriptBlock { Restart-service TermService -force }
|
||||
|
||||
Invoke-Command -Session $s -ScriptBlock { start-service UmRdpService }
|
||||
Invoke-Command -Session $s -ScriptBlock { start-service TermService }
|
||||
Invoke-Command -Session $s -ScriptBlock { start-service ServicesManager }
|
||||
|
||||
#check LicenseManager services and dependants
|
||||
Invoke-Command -Session $s -ScriptBlock { get-service LicenseManager }
|
||||
|
||||
#restart LicenseManager
|
||||
Invoke-Command -Session $s -ScriptBlock { Restart-service LicenseManager }
|
||||
|
||||
#get firewall profiles
|
||||
Invoke-Command -Session $s -ScriptBlock { Get-NetFirewallProfile }
|
||||
|
||||
#disable firewall
|
||||
Invoke-Command -Session $s -ScriptBlock {netsh advfirewall set allprofiles state off }
|
||||
#checlk firewall
|
||||
Invoke-Command -Session $s -ScriptBlock {netsh advfirewall show all}
|
||||
|
||||
|
||||
#checlk firewall rules
|
||||
Invoke-Command -Session $s -ScriptBlock {Get-NetFirewallServiceFilter -Service termservice | Get-NetFirewallRule}
|
||||
|
||||
|
||||
|
||||
|
||||
#Open port
|
||||
Invoke-Command -Session $s -ScriptBlock {netsh advfirewall firewall add rule name="TCP Port 3389" dir=in action=allow protocol=TCP localport=3389}
|
||||
Invoke-Command -Session $s -ScriptBlock {New-NetFirewallRule -DisplayName 'open rdp' -Profile 'Domain, Private, Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3389}
|
||||
|
||||
|
||||
#check port
|
||||
Invoke-Command -Session $s -ScriptBlock {get-NetFirewallRule -LocalOnlyMapping}
|
||||
|
||||
#check port
|
||||
Invoke-Command -Session $s -ScriptBlock {netstat -ano | findStr "80"}
|
||||
|
||||
#check port
|
||||
Invoke-Command -Session $s -ScriptBlock {netstat -ano | findStr "3389"}
|
||||
|
||||
#check port
|
||||
Invoke-Command -Session $s -ScriptBlock {Get-NetTCPConnection -LocalPort 3389}
|
||||
|
||||
#check port
|
||||
Invoke-Command -Session $s -ScriptBlock {Get-NetFirewallPortFilter | Where-Object -Property LocalPort -EQ 3389}
|
||||
|
||||
#check blocked port
|
||||
Invoke-Command -Session $s -ScriptBlock {get-NetFirewallRule -Action Block}
|
||||
|
||||
#check NotConfigured port
|
||||
Invoke-Command -Session $s -ScriptBlock {get-NetFirewallRule -Action NotConfigured}
|
||||
|
||||
#Invoke-Command -Session $s -ScriptBlock {new-item \\roser.rosercloud.app\d$\temp\Pierre_emergency_rpvda03\firewallrules.txt }
|
||||
|
||||
#check connectivity remotely
|
||||
Invoke-Command -Session $s -ScriptBlock {tnc rpvda03 -port 3389}
|
||||
|
||||
#check connectivity remotely
|
||||
Invoke-Command -Session $s -ScriptBlock {telnet 127.0.0.1 3389}
|
||||
|
||||
#get GPO
|
||||
Invoke-Command -Session $s -ScriptBlock {Get-GPO -All}
|
||||
|
||||
#get date
|
||||
Invoke-Command -Session $s -ScriptBlock {date}
|
||||
|
||||
#Get recent entries from an event log on the local computer
|
||||
Invoke-Command -Session $s -ScriptBlock {Get-EventLog -LogName System -Newest 50}
|
||||
|
||||
#Get recent entries from an event log on the local computer
|
||||
Invoke-Command -Session $s -ScriptBlock {Get-EventLog -LogName Application -Newest 50}
|
||||
|
||||
#Get all events that include a specific word in the message
|
||||
Invoke-Command -Session $s -ScriptBlock {Get-EventLog -LogName Application -Message *TermService*}
|
||||
|
||||
|
||||
Invoke-Command -Session $s -ScriptBlock {Get-WinEvent -FilterHashTable @{LogName='Microsoft-Windows-TerminalServices-RDPClient/Operational'} | Select-Object $properties}
|
||||
|
||||
# determine the current RDP por
|
||||
Invoke-Command -Session $s -ScriptBlock {Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber"}
|
||||
|
||||
# change the current RDP por
|
||||
Invoke-Command -Session $s -ScriptBlock {
|
||||
$portvalue=3389
|
||||
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue
|
||||
}
|
||||
|
||||
|
||||
#change the default port value
|
||||
Invoke-Command -Session $s -ScriptBlock {
|
||||
$portvalue = 3389
|
||||
|
||||
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue
|
||||
|
||||
New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue
|
||||
New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
|
||||
Restart-service UmRdpService
|
||||
Restart-service TermService -force
|
||||
tnc rpvda03 -port $portvalue
|
||||
}
|
||||
|
||||
# ping 8.8.8.8
|
||||
Invoke-Command -Session $s -ScriptBlock {ping 8.8.8.8}
|
||||
|
||||
Invoke-Command -Session $s -ScriptBlock {
|
||||
$properties = @( @{n='TimeStamp';e={$_.TimeCreated}} @{n='LocalUser';e={$_.UserID}} @{n='Target RDP host';e={$_.Properties[1].Value}} ) Get-WinEvent -FilterHashTable @{LogName='Microsoft-Windows-TerminalServices-RDPClient/Operational';ID='1102'} | Select-Object $properties
|
||||
}
|
||||
|
||||
|
||||
Invoke-Command -Session $s -ScriptBlock {Get-WmiObject -Class Win32_Service -Filter "Name LIKE 'TermService'" }
|
||||
Invoke-Command -Session $s -ScriptBlock {
|
||||
|
||||
|
||||
$id = Get-WmiObject -Class Win32_Service -Filter "Name LIKE 'TermService'" |
|
||||
Select-Object -ExpandProperty ProcessId
|
||||
Get-WmiObject -Class Win32_Service -Filter "Name LIKE 'TermService'"
|
||||
$process = Get-Process -Id $id
|
||||
$process
|
||||
#kill $process
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
$Realm='ZR'
|
||||
$Keycloak_Server = "https://keycloak.roser-ict.com"
|
||||
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
$CLientID = 'CLientID'
|
||||
$ClientSecret = 'ClientSecret'
|
||||
if(-not $ClientSecret) {
|
||||
Write-Error 'Please configure $ClientSecret' -ErrorAction STOP
|
||||
}
|
||||
|
||||
$RequestURL = $Keycloak_Server + "/auth/realms/$Realm/protocol/openid-connect/token"
|
||||
|
||||
$body = @{
|
||||
grant_type='client_credentials'
|
||||
client_id=$ClientID
|
||||
client_secret=$ClientSecret
|
||||
}
|
||||
|
||||
# Token Request
|
||||
$result = Invoke-WebRequest -Method POST -Uri $RequestURL -ContentType "application/x-www-form-urlencoded" -Body $body
|
||||
|
||||
$Content = $result.Content | ConvertFrom-Json
|
||||
$APIurl = 'https://totalzr-rsa-acc.roser-ict.com/api/configuration/languages'
|
||||
$Params = @{
|
||||
"URI" = $APIurl
|
||||
"Method" = 'GET'
|
||||
"Headers" = @{
|
||||
"Content-Type" = 'application/json'
|
||||
"Authorization" = "Bearer $($Content.access_token)"
|
||||
}
|
||||
}
|
||||
|
||||
Invoke-RestMethod @Params
|
||||
@@ -0,0 +1,10 @@
|
||||
$disconnected_users = qwinsta | select-string "Disc" | select-string -notmatch "services"
|
||||
|
||||
if ($disconnected_users )
|
||||
{
|
||||
$disconnected_users|ForEach-Object{
|
||||
write-output "kickoff of :"
|
||||
write-output ($_.tostring() -split ' +')[1]
|
||||
logoff ($_.tostring() -split ' +')[2]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
$VerbosePreference='continue'
|
||||
######################################################################################
|
||||
#
|
||||
# Servers you want to connect
|
||||
#
|
||||
######################################################################################
|
||||
|
||||
$list_of_server_to_connect = @("BP-srvapp25","BP-srvapp26","BP-srvapp27")
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
#
|
||||
# Command to type
|
||||
#
|
||||
######################################################################################
|
||||
|
||||
#if password is required
|
||||
#$username =
|
||||
#$password =
|
||||
$Source_patch_folder = "C:\Users\pgeeraert_a\Desktop\2020.01.44.216\Roser Suite\RoserSuite_2020.01_Release_x64_216\"
|
||||
$Destination_patch_folder = "C:\Users\pgeeraert_a\Desktop"
|
||||
|
||||
foreach($server in $list_of_server_to_connect){
|
||||
|
||||
#--Uncomment if password is required
|
||||
#$pw = convertto-securestring -AsPlainText -Force -String $password
|
||||
#$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$pw
|
||||
#$Session = New-PSSession -ComputerName $server -Credential $cred
|
||||
#--
|
||||
|
||||
#--Comment if password i srequired
|
||||
$Session = New-PSSession -ComputerName $server
|
||||
#--
|
||||
|
||||
write-output "connecting to $server"
|
||||
Copy-Item $Source_patch_folder -Destination $Destination_patch_folder -ToSession $Session -Recurse -Force
|
||||
|
||||
write-output "Copy of $server done"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
|
||||
# Keycloak Server
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$Keycloak_Server = 'https://keycloak-acc-bp-weu.roser-ict.com',
|
||||
|
||||
# ClientID From Keycloak
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$ClientID = 'BP_Rotterdam',
|
||||
|
||||
# ClientSecret From Keycloak
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$ClientSecret = 'a2bb4f34-d415-4cba-807f-c68a41b9cb3c',
|
||||
|
||||
# Keycloak Realm
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$Realm='BP_Rotterdam'
|
||||
|
||||
)
|
||||
|
||||
|
||||
$VerbosePreference='continue'
|
||||
|
||||
# Example Powershell Code for connecting to the API and retrieving supported languages
|
||||
$APIswagger = 'https://api-acc-bp-weu.roser-ict.com/api/welding/swagger.yml'
|
||||
$APIlanguages = 'https://api-acc-bp-weu.roser-ict.com/api/configuration/languages'
|
||||
$APIwelding = 'https://api-acc-bp-weu.roser-ict.com/api/welding/report'
|
||||
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
if(-not $ClientSecret) {
|
||||
Write-Error 'Please configure $ClientSecret' -ErrorAction STOP
|
||||
}
|
||||
|
||||
$RequestURL = $Keycloak_Server + "/auth/realms/$Realm/protocol/openid-connect/token"
|
||||
|
||||
$body = @{
|
||||
grant_type='client_credentials'
|
||||
client_id=$ClientID
|
||||
client_secret=$ClientSecret
|
||||
}
|
||||
|
||||
# Token Request
|
||||
$result = Invoke-WebRequest -Method POST -Uri $RequestURL -ContentType "application/x-www-form-urlencoded" -Body $body
|
||||
$Content = $result.Content | ConvertFrom-Json
|
||||
|
||||
$Params = @{
|
||||
"URI" = $APIswagger
|
||||
"Method" = 'GET'
|
||||
"Headers" = @{
|
||||
"Content-Type" = 'application/json'
|
||||
"Authorization" = "Bearer $($Content.access_token)"
|
||||
}
|
||||
}
|
||||
$Swagger = Invoke-RestMethod @Params
|
||||
|
||||
Write-Output $Swagger
|
||||
|
||||
|
||||
$Params = @{
|
||||
"URI" = $APIlanguages
|
||||
"Method" = 'GET'
|
||||
"Headers" = @{
|
||||
"Content-Type" = 'application/json'
|
||||
"Authorization" = "Bearer $($Content.access_token)"
|
||||
}
|
||||
}
|
||||
Invoke-RestMethod @Params
|
||||
|
||||
$Params = @{
|
||||
"URI" = $APIwelding
|
||||
"Method" = 'POST'
|
||||
"Headers" = @{
|
||||
"Content-Type" = 'application/json'
|
||||
"Authorization" = "Bearer $($Content.access_token)"
|
||||
}
|
||||
}
|
||||
Invoke-RestMethod @Params -Verbose
|
||||
|
||||
$Params.Method = 'GET'
|
||||
$WelditReports = Invoke-RestMethod @Params -Verbose
|
||||
|
||||
write-output "Received $($WelditReports.Count) Reports"
|
||||
@@ -0,0 +1,9 @@
|
||||
get-adcomputer -filter * | ForEach-Object {
|
||||
|
||||
Invoke-Command -ComputerName $psitem.DnsHostName -ScriptBlock {
|
||||
Get-Service *roser*;
|
||||
|
||||
#get-service *push*;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
$VerbosePreference='continue'
|
||||
######################################################################################
|
||||
#
|
||||
# Servers you want to connect
|
||||
#
|
||||
######################################################################################
|
||||
|
||||
$list_of_server_to_connect = [ordered]@{
|
||||
"te-prd-app-01" = [PSCustomObject]@{
|
||||
"Name"="te-prd-app-01.roser-total.local"
|
||||
"username"="roser-total\pgeeraert"
|
||||
"password"="Pr0m3th3us!!"
|
||||
}
|
||||
}
|
||||
|
||||
######################################################################################
|
||||
#
|
||||
# Command to type
|
||||
#
|
||||
######################################################################################
|
||||
|
||||
$command_to_type = hostname
|
||||
|
||||
|
||||
|
||||
|
||||
$pw = convertto-securestring -AsPlainText -Force -String "Pr0m3th3us!!"
|
||||
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "roser-total\pgeeraert",$pw
|
||||
$server_to_connect = $list_of_server_to_connect.$server.Name
|
||||
$session = New-PSSession -ComputerName $server_to_connect -Credential $cred
|
||||
Invoke-Command -Session $session -ScriptBlock { hostname }
|
||||
|
||||
<#
|
||||
foreach($server in $list_of_server_to_connect.keys){
|
||||
write-output $server
|
||||
write-output $list_of_server_to_connect.$server.Name
|
||||
$pw = convertto-securestring -AsPlainText -Force -String $list_of_server_to_connect.$server.password
|
||||
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $list_of_server_to_connect.$server.username,$pw
|
||||
|
||||
$server_to_connect = $list_of_server_to_connect.$server.Name
|
||||
$session = New-PSSession -ComputerName $server_to_connect -Credential $cred
|
||||
Invoke-Command -Session $session -ScriptBlock { hostname }
|
||||
}
|
||||
|
||||
#get the target
|
||||
#>
|
||||
@@ -0,0 +1,20 @@
|
||||
$VerbosePreference = 'continue'
|
||||
get-adcomputer -Filter 'Name -like "te-prd-app-*"' | ForEach-Object {
|
||||
Write-Verbose $PSItem.name
|
||||
Invoke-Command -ComputerName $psitem.DnsHostName -ScriptBlock {
|
||||
hostname;
|
||||
$VerbosePreference = 'continue'
|
||||
|
||||
$sites = "antwerp","donges","feyzin","grandpuits","leuna","normandie","portarthur"
|
||||
|
||||
foreach($site in $sites){
|
||||
|
||||
Write-Verbose $site
|
||||
if((Get-ACl C:\roserapps\$site).Access | Where-Object {$_.IdentityReference -eq "ROSER-TOTAL\NFZ_$site"}){
|
||||
(Get-ACl C:\roserapps\$site).Access | Where-Object {$_.IdentityReference -eq "ROSER-TOTAL\NFZ_$site"}}
|
||||
else{
|
||||
write-error "not there"}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
get-adcomputer -filter "name -like 'tot-ctx-*'" | ForEach-Object {
|
||||
|
||||
Get-FileHash -Path "\\$($Psitem.DnsHostname)\c$\P6IntegrationAPI_1\BREBootStrap.xml"
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
$file = "C:\Users\pgeeraert\Downloads\connections.xml"
|
||||
$destination = Get-content $file
|
||||
|
||||
|
||||
$data = foreach ($line in $destination) {
|
||||
$info = $line -split "\s+"
|
||||
$hash = [ordered]@{}
|
||||
for ($i=0;$i -lt $names.count;$i++) {
|
||||
$hash.add($names[$i],$Info[$i])
|
||||
} #end For
|
||||
[pscustomobject]$hash
|
||||
} #end Foreach
|
||||
|
||||
$data
|
||||
@@ -0,0 +1 @@
|
||||
$reg_key_to_delete = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod\' | Select-Object L$RTM*
|
||||
@@ -0,0 +1,14 @@
|
||||
$VerbosePreference = "continue"
|
||||
$Jira_number = Read-Host ""
|
||||
|
||||
if(-Not($Jira_number -like "DEPLOY*")){
|
||||
write-output "no deploy in there"
|
||||
$Jira_number = "DEPLOY-$Jira_number"
|
||||
}
|
||||
write-verbose $Jira_number
|
||||
$url = "https://prometheusgroup.atlassian.net/browse/$Jira_number"
|
||||
|
||||
Start-Process $url
|
||||
|
||||
|
||||
Start-Sleep -Seconds 10
|
||||
@@ -0,0 +1,57 @@
|
||||
$VerbosePreference = "continue"
|
||||
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
$form = New-Object System.Windows.Forms.Form
|
||||
$form.Text = 'Jira task'
|
||||
$form.Size = New-Object System.Drawing.Size(300,200)
|
||||
$form.StartPosition = 'CenterScreen'
|
||||
|
||||
$okButton = New-Object System.Windows.Forms.Button
|
||||
$okButton.Location = New-Object System.Drawing.Point(75,120)
|
||||
$okButton.Size = New-Object System.Drawing.Size(75,23)
|
||||
$okButton.Text = 'OK'
|
||||
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
|
||||
$form.AcceptButton = $okButton
|
||||
$form.Controls.Add($okButton)
|
||||
|
||||
$cancelButton = New-Object System.Windows.Forms.Button
|
||||
$cancelButton.Location = New-Object System.Drawing.Point(150,120)
|
||||
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
|
||||
$cancelButton.Text = 'Cancel'
|
||||
$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
|
||||
$form.CancelButton = $cancelButton
|
||||
$form.Controls.Add($cancelButton)
|
||||
|
||||
$label = New-Object System.Windows.Forms.Label
|
||||
$label.Location = New-Object System.Drawing.Point(10,20)
|
||||
$label.Size = New-Object System.Drawing.Size(280,20)
|
||||
$label.Text = 'Please enter the Jira task number:'
|
||||
$form.Controls.Add($label)
|
||||
|
||||
$textBox = New-Object System.Windows.Forms.TextBox
|
||||
$textBox.Location = New-Object System.Drawing.Point(10,40)
|
||||
$textBox.Size = New-Object System.Drawing.Size(260,20)
|
||||
$form.Controls.Add($textBox)
|
||||
|
||||
$form.Topmost = $true
|
||||
|
||||
$form.Add_Shown({$textBox.Select()})
|
||||
$result = $form.ShowDialog()
|
||||
|
||||
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
|
||||
{
|
||||
$Jira_number = $textBox.Text
|
||||
|
||||
if(-Not($Jira_number -like "DEPLOY*")){
|
||||
Write-Verbose $Jira_number
|
||||
write-verbose "no deploy in there"
|
||||
$Jira_number = "DEPLOY-$Jira_number"
|
||||
}
|
||||
write-verbose $Jira_number
|
||||
$url = "https://prometheusgroup.atlassian.net/browse/$Jira_number"
|
||||
|
||||
Start-Process $url
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
#########################################################################################
|
||||
#
|
||||
# Ownership taker
|
||||
#
|
||||
#########################################################################################
|
||||
# this script can be use to take the ownership of an account
|
||||
# specify your name in the list of $list_of_known_users with your autologonname (put your login name if you don't know your Pbkdf2 Hash)
|
||||
# and put the name of your object in the variable $own_user_objectName
|
||||
# then execute the script, specifiy the targeted user and the targeted database(s)
|
||||
# if you want to revert back the configuration, replace the variable $own_user_objectName with the name of the object of the person you took the ownership
|
||||
|
||||
#########################################################################################
|
||||
#
|
||||
# Database Value
|
||||
#
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#other
|
||||
#$DBInstance = 'DB NAME'#
|
||||
|
||||
|
||||
#$DBACredential = Get-Credential -UserName pgadmin -Message "Credentials for $DBInstance"
|
||||
#DBPassword = $DBACredential.GetNetworkCredential().Password
|
||||
#$DBUsername = $DBACredential.UserName
|
||||
|
||||
|
||||
#Database=$database
|
||||
$ConnectionString = "Server=$DBInstance;User Id=$DBUsername;Password=$DBPassword;TrustServerCertificate=True"
|
||||
$VerbosePreference = 'Continue'
|
||||
|
||||
|
||||
#########################################################################################
|
||||
#
|
||||
# User value
|
||||
#
|
||||
#########################################################################################
|
||||
|
||||
$list_of_known_users = [ordered]@{
|
||||
Admin = [PSCustomObject]@{
|
||||
"Name"="Admin"
|
||||
"username"="admin"
|
||||
"autologonname"=""
|
||||
};
|
||||
Administrator = [PSCustomObject]@{
|
||||
"Name"="Administrator"
|
||||
"username"="administrator"
|
||||
"autologonname"=""
|
||||
};
|
||||
Anastasia = [PSCustomObject]@{
|
||||
"Name"="Anastasia"
|
||||
"username"="akroupkina"
|
||||
"autologonname"=""
|
||||
};
|
||||
Henry = [PSCustomObject]@{
|
||||
"Name"="Henry"
|
||||
"username"="hchung"
|
||||
"autologonname"=""
|
||||
};
|
||||
Frans = [PSCustomObject]@{
|
||||
"Name"="Frans"
|
||||
"username"="frans"
|
||||
"autologonname"=""
|
||||
};
|
||||
Blake = [PSCustomObject]@{
|
||||
"Name"="Blake"
|
||||
"username"="bparrish"
|
||||
"autologonname"=""
|
||||
};
|
||||
Besfort = [PSCustomObject]@{
|
||||
"Name"="Besfort"
|
||||
"username"="bhyseni"
|
||||
"autologonname"=""
|
||||
};
|
||||
Kyle = [PSCustomObject]@{
|
||||
"Name"="Kyle"
|
||||
"username"="kpatel"
|
||||
"autologonname"=""
|
||||
};
|
||||
Pierre = [PSCustomObject]@{
|
||||
"Name"="Pierre"
|
||||
"username"="pierretotal"
|
||||
"autologonname"=""
|
||||
}
|
||||
}
|
||||
|
||||
#########################################################################################
|
||||
# Fill with your user object name
|
||||
#########################################################################################
|
||||
$own_user_objectName = 'Pierre'
|
||||
|
||||
$ownAutologonname = $list_of_known_users.$own_user_objectName.autologonname
|
||||
|
||||
|
||||
#get the target
|
||||
$targetObjectName = $list_of_known_users.keys |Out-GridView -PassThru -Title "Select the target"
|
||||
|
||||
$targetName = $list_of_known_users.$targetObjectName.Name
|
||||
$targetUserName = $list_of_known_users.$targetObjectName.Username
|
||||
|
||||
Write-output "You selected the user $targetName to take ownership "
|
||||
|
||||
$QuerySelectDatabases= "SELECT name FROM sys.databases order by name"
|
||||
$targeted_DB= Invoke-Sqlcmd -ConnectionString $ConnectionString -Query $QuerySelectDatabases |Out-GridView -PassThru -Title "Select the targeted databases"
|
||||
|
||||
|
||||
foreach( $database in $targeted_DB ) {
|
||||
$DB_name = $database.Name
|
||||
write-output "updating $DB_name"
|
||||
|
||||
|
||||
|
||||
$queryVerifyPresenceUser = "
|
||||
SELECT
|
||||
CASE WHEN EXISTS
|
||||
(
|
||||
select pk_userid,username, createcomputer , firstname, lastname , autologonname, isactive from $DB_name.dbo.tblUser where username = '$targetUserName'
|
||||
)
|
||||
THEN 'TRUE'
|
||||
ELSE 'FALSE'
|
||||
END
|
||||
"
|
||||
write-output $queryVerifyPresenceUser
|
||||
$boolean_presence_users = Invoke-Sqlcmd -ConnectionString $ConnectionString -Query $queryVerifyPresenceUser
|
||||
write-verbose $boolean_presence_users.Column1
|
||||
if($boolean_presence_users.Column1 -eq "FALSE"){
|
||||
write-output "the user doesn't exist in the following database : $DB_name"
|
||||
continue
|
||||
}
|
||||
|
||||
$QueryUpdatingUser= "
|
||||
update $DB_name.dbo.tblUser
|
||||
set isactive = 1,
|
||||
autologonname = '$ownAutologonname'
|
||||
where username = '$targetUserName';
|
||||
"
|
||||
Write-Output "Query to execute :"
|
||||
Write-Output $QueryUpdatingUser
|
||||
Write-Warning "Are you sure to proceed ?" -WarningAction Inquire
|
||||
Invoke-Sqlcmd -ConnectionString $ConnectionString -Query $QueryUpdatingUser
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<#
|
||||
.Synopsis
|
||||
Delete the specific object with the following parameters
|
||||
|
||||
.Parameter -path
|
||||
path of the folder to look for the files ,this is MANDATORY
|
||||
|
||||
.Parameter -retention_number_of_day
|
||||
Value for the number of day the files needs to be older to be deleted, this is MANDATORY
|
||||
|
||||
.Parameter -pattern_to_delete
|
||||
Pattern to target if you need to delete a specific extension or pattern within the filename, this is OPTIONAL
|
||||
if you want to specify only the filename put it without any sign
|
||||
Example : -pattern_to_delete "catalina"
|
||||
|
||||
if you want to target extension name specify the dot
|
||||
Example : -pattern_to_delete ".log"
|
||||
|
||||
If you want to specify a specific filename and an extension, just add the * between the word
|
||||
Example : -pattern_to_delete "catalina*.log"
|
||||
|
||||
.Parameter -recurse_boolean
|
||||
option to search recursively or not, this is OPTIONAL , DEFAULT = $false
|
||||
|
||||
.Parameter -dry_run_boolean
|
||||
option to perform dry run and display what would be deleted this is OPTIONAL , DEFAULT = $false
|
||||
|
||||
.Example
|
||||
# delete all the log files within the C:\Users\USER\Documents directory for the files older than 30 days with the name log within their name or extension
|
||||
deletion_of_specific_objects -path "C:\Users\USER\Documents" -retention_number_of_day 30 -pattern_to_delete "log"
|
||||
|
||||
# delete all the files within the C:\Users\USER\Documents directory for all the files within all the folder
|
||||
deletion_of_specific_objects -path "C:\Users\USER\Documents" -retention_number_of_day 0 -recurse_boolean $true
|
||||
|
||||
#>
|
||||
|
||||
function deletion_of_specific_objects{
|
||||
param(
|
||||
[Parameter (Mandatory = $true)] [String]$path,
|
||||
[Parameter (Mandatory = $false)] [String]$pattern_to_delete,
|
||||
[Parameter (Mandatory = $true)] [Int]$retention_number_of_day,
|
||||
[Parameter (Mandatory = $false)] [boolean]$recurse_boolean = $false,
|
||||
[Parameter (Mandatory = $false)] [boolean]$dry_run_boolean = $false
|
||||
)
|
||||
$recurse_boolean_parameter = @{Recurse = $recurse_boolean}
|
||||
$Dry_run = @{Whatif = $dry_run_boolean}
|
||||
|
||||
Get-ChildItem -Path $path/* -File -Include *$pattern_to_delete* @recurse_boolean_parameter |Where CreationTime -lt (Get-Date).AddDays(-$retention_number_of_day)|Remove-Item @Dry_run
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
|
||||
deletion_of_specific_objects -path "C:\Users\USER\Documents" -retention_number_of_day 30 -pattern_to_delete "*.log" -recurse_boolean $true -dry_run_boolean $false
|
||||
@@ -0,0 +1,32 @@
|
||||
$VerbosePreference='continue'
|
||||
|
||||
|
||||
|
||||
$Server= 'tot-ctx-prd02'
|
||||
|
||||
$Profiles = Get-ChildItem -Directory \\$Server\c$\users | Select-Object -ExpandProperty name
|
||||
|
||||
$OU='OU=User Accounts,OU=roser-total,DC=roser-total,DC=local'
|
||||
$ADusers= Get-ADuser -filter * -SearchBase $OU | Where-Object { $Profiles -ccontains $psitem.samaccountname }
|
||||
|
||||
|
||||
|
||||
|
||||
Get-ADComputer -filter "name -like '$Server'" | ForEach-Object {
|
||||
|
||||
Write-Verbose $psitem.DNSHostname
|
||||
|
||||
Invoke-Command -ComputerName $psitem.DNSHostname -ScriptBlock { $VerbosePreference='continue';
|
||||
|
||||
|
||||
|
||||
foreach($sid in $args) {
|
||||
|
||||
Write-Verbose $SID
|
||||
Get-WMIObject -class Win32_UserProfile -Filter "SID='$sid'" | Remove-WmiObject -Verbose
|
||||
|
||||
}
|
||||
|
||||
} -ArgumentList ($ADusers).SID
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
$VerbosePreference = "continue"
|
||||
Start-Transcript C:\Users\pgeeraert_a\Desktop\DEPLOY-27258\Attachements\transcripts_copy.txt
|
||||
|
||||
copy-item \\roser-bp.local\shares\RoserBPFiles\whiting\97055c44-7b7a-4cac-9196-e7a63b838cd8.pdf C:\Users\pgeeraert_a\Desktop\DEPLOY-27258\Attachements
|
||||
|
||||
Stop-Transcript
|
||||
Reference in New Issue
Block a user